Merge remote-tracking branch 'origin/master'
@@ -255,7 +255,8 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
|
||||
protected boolean removeLibrary(final Library library) {
|
||||
final LibraryTable table = library.getTable();
|
||||
if (table != null) {
|
||||
final Collection<ProjectStructureElementUsage> usages = myContext.getDaemonAnalyzer().getUsages(new LibraryProjectStructureElement(myContext, library));
|
||||
final LibraryProjectStructureElement libraryElement = new LibraryProjectStructureElement(myContext, library);
|
||||
final Collection<ProjectStructureElementUsage> usages = new ArrayList<ProjectStructureElementUsage>(myContext.getDaemonAnalyzer().getUsages(libraryElement));
|
||||
if (usages.size() > 0) {
|
||||
final MultiMap<String, ProjectStructureElementUsage> containerType2Usage = new MultiMap<String, ProjectStructureElementUsage>();
|
||||
for (final ProjectStructureElementUsage usage : usages) {
|
||||
@@ -295,12 +296,12 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
|
||||
}
|
||||
|
||||
getModelProvider().getModifiableModel().removeLibrary(library);
|
||||
myContext.getDaemonAnalyzer().removeElement(new LibraryProjectStructureElement(myContext, library));
|
||||
myContext.getDaemonAnalyzer().removeElement(libraryElement);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
getModelProvider().getModifiableModel().removeLibrary(library);
|
||||
myContext.getDaemonAnalyzer().removeElement(new LibraryProjectStructureElement(myContext, library));
|
||||
myContext.getDaemonAnalyzer().removeElement(libraryElement);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public class MarkerType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
ClassInheritorsSearch.search(myClass, ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
|
||||
@Override
|
||||
@@ -255,7 +255,10 @@ public class MarkerType {
|
||||
}), true).forEach(new CommonProcessors.CollectProcessor<PsiClass>() {
|
||||
@Override
|
||||
public boolean process(final PsiClass o) {
|
||||
updateComponent(o, myRenderer.getComparator());
|
||||
if (!updateComponent(o, myRenderer.getComparator())) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
return super.process(o);
|
||||
}
|
||||
});
|
||||
@@ -281,13 +284,16 @@ public class MarkerType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
OverridingMethodsSearch.search(myMethod, true).forEach(
|
||||
new CommonProcessors.CollectProcessor<PsiMethod>() {
|
||||
@Override
|
||||
public boolean process(PsiMethod psiMethod) {
|
||||
updateComponent(psiMethod, myRenderer.getComparator());
|
||||
if (!updateComponent(psiMethod, myRenderer.getComparator())) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
return super.process(psiMethod);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,365 +0,0 @@
|
||||
/*
|
||||
* 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.jps.incremental.java;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.misc.Resource;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
class ClassFinderClasspath {
|
||||
private static final String FILE_PROTOCOL = "file";
|
||||
|
||||
private final Stack<URL> myUrls = new Stack<URL>();
|
||||
private final List<Loader> myLoaders = new ArrayList<Loader>();
|
||||
private final Map<URL,Loader> myLoadersMap = new HashMap<URL, Loader>();
|
||||
|
||||
public ClassFinderClasspath(URL[] urls) {
|
||||
push(urls);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(String s, boolean flag) {
|
||||
int i = 0;
|
||||
for (Loader loader; (loader = getLoader(i)) != null; i++) {
|
||||
Resource resource = loader.getResource(s, flag);
|
||||
if (resource != null) {
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
for (Loader loader : myLoaders) {
|
||||
loader.releaseResources();
|
||||
}
|
||||
myLoaders.clear();
|
||||
myLoadersMap.clear();
|
||||
myUrls.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private synchronized Loader getLoader(int i) {
|
||||
while (myLoaders.size() < i + 1) {
|
||||
URL url;
|
||||
synchronized (myUrls) {
|
||||
if (myUrls.empty()) {
|
||||
return null;
|
||||
}
|
||||
url = myUrls.pop();
|
||||
}
|
||||
|
||||
if (myLoadersMap.containsKey(url)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Loader loader;
|
||||
try {
|
||||
loader = getLoader(url, myLoaders.size());
|
||||
if (loader == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
myLoaders.add(loader);
|
||||
myLoadersMap.put(url, loader);
|
||||
}
|
||||
|
||||
return myLoaders.get(i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Loader getLoader(final URL url, int index) throws IOException {
|
||||
String s;
|
||||
try {
|
||||
s = url.toURI().getSchemeSpecificPart();
|
||||
}
|
||||
catch (URISyntaxException thisShouldNotHappen) {
|
||||
thisShouldNotHappen.printStackTrace();
|
||||
s = url.getFile();
|
||||
}
|
||||
|
||||
Loader loader = null;
|
||||
if (s != null && new File(s).isDirectory()) {
|
||||
if (FILE_PROTOCOL.equals(url.getProtocol())) {
|
||||
loader = new FileLoader(url, index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
loader = new JarLoader(url, index);
|
||||
}
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
private void push(URL[] urls) {
|
||||
if (urls.length == 0) return;
|
||||
synchronized (myUrls) {
|
||||
for (int i = urls.length - 1; i >= 0; i--) {
|
||||
myUrls.push(urls[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private abstract static class Loader {
|
||||
protected static final String JAR_PROTOCOL = "jar";
|
||||
protected static final String FILE_PROTOCOL = "file";
|
||||
|
||||
private final URL myURL;
|
||||
private final int myIndex;
|
||||
|
||||
protected Loader(URL url, int index) {
|
||||
myURL = url;
|
||||
myIndex = index;
|
||||
}
|
||||
|
||||
|
||||
protected URL getBaseURL() {
|
||||
return myURL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract Resource getResource(final String name, boolean flag);
|
||||
|
||||
public abstract void releaseResources();
|
||||
|
||||
public int getIndex() {
|
||||
return myIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class FileLoader extends Loader {
|
||||
private final File myRootDir;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
FileLoader(URL url, int index) throws IOException {
|
||||
super(url, index);
|
||||
if (!FILE_PROTOCOL.equals(url.getProtocol())) {
|
||||
throw new IllegalArgumentException("url");
|
||||
}
|
||||
else {
|
||||
final String s = FileUtil.unquote(url.getFile());
|
||||
myRootDir = new File(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(final String name, boolean check) {
|
||||
URL url = null;
|
||||
File file = null;
|
||||
|
||||
try {
|
||||
url = new URL(getBaseURL(), name);
|
||||
if (!url.getFile().startsWith(getBaseURL().getFile())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
file = new File(myRootDir, name.replace('/', File.separatorChar));
|
||||
if (!check || file.exists()) { // check means we load or process resource so we check its existence via old way
|
||||
return new FileResource(name, url, file, !check);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (!check && file != null && file.exists()) {
|
||||
try { // we can not open the file if it is directory, Resource still can be created
|
||||
return new FileResource(name, url, file, false);
|
||||
}
|
||||
catch (IOException ex) {}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class FileResource extends Resource {
|
||||
private final String myName;
|
||||
private final URL myUrl;
|
||||
private final File myFile;
|
||||
|
||||
public FileResource(String name, URL url, File file, boolean willLoadBytes) throws IOException {
|
||||
myName = name;
|
||||
myUrl = url;
|
||||
myFile = file;
|
||||
if (willLoadBytes) getByteBuffer(); // check for existence by creating cached file input stream
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public URL getCodeSourceURL() {
|
||||
return getBaseURL();
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new BufferedInputStream(new FileInputStream(myFile));
|
||||
}
|
||||
|
||||
public int getContentLength() throws IOException {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myFile.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "FileLoader [" + myRootDir + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private class JarLoader extends Loader {
|
||||
private final URL myURL;
|
||||
private ZipFile myZipFile;
|
||||
|
||||
JarLoader(URL url, int index) throws IOException {
|
||||
super(new URL(JAR_PROTOCOL, "", -1, url + "!/"), index);
|
||||
myURL = url;
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
final ZipFile zipFile = myZipFile;
|
||||
if (zipFile != null) {
|
||||
myZipFile = null;
|
||||
try {
|
||||
zipFile.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ZipFile acquireZipFile() throws IOException {
|
||||
ZipFile zipFile = myZipFile;
|
||||
if (zipFile == null) {
|
||||
zipFile = doGetZipFile();
|
||||
myZipFile = zipFile;
|
||||
}
|
||||
return zipFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ZipFile doGetZipFile() throws IOException {
|
||||
if (FILE_PROTOCOL.equals(myURL.getProtocol())) {
|
||||
String s = FileUtil.unquote(myURL.getFile());
|
||||
if (!new File(s).exists()) {
|
||||
throw new FileNotFoundException(s);
|
||||
}
|
||||
else {
|
||||
return new ZipFile(s);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(String name, boolean flag) {
|
||||
try {
|
||||
final ZipFile file = acquireZipFile();
|
||||
if (file != null) {
|
||||
final ZipEntry entry = file.getEntry(name);
|
||||
if (entry != null) {
|
||||
return new JarResource(entry, new URL(getBaseURL(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class JarResource extends Resource {
|
||||
private final ZipEntry myEntry;
|
||||
private final URL myUrl;
|
||||
|
||||
public JarResource(ZipEntry name, URL url) {
|
||||
myEntry = name;
|
||||
myUrl = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myEntry.getName();
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public URL getCodeSourceURL() {
|
||||
return myURL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream getInputStream() throws IOException {
|
||||
ZipFile file = null;
|
||||
try {
|
||||
file = acquireZipFile();
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final InputStream inputStream = file.getInputStream(myEntry);
|
||||
if (inputStream == null) {
|
||||
return null; // if entry was not found
|
||||
}
|
||||
return new FilterInputStream(inputStream) {};
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getContentLength() {
|
||||
return (int)myEntry.getSize();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "JarLoader [" + myURL + "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
package org.jetbrains.jps.incremental.java;
|
||||
|
||||
import org.jetbrains.jps.javac.OutputFileObject;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.objectweb.asm.Attribute;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.commons.EmptyVisitor;
|
||||
import sun.misc.Resource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 2/16/12
|
||||
*/
|
||||
class InstrumentationClassFinder {
|
||||
public class InstrumentationClassFinder {
|
||||
private static final PseudoClass[] EMPTY_PSEUDOCLASS_ARRAY = new PseudoClass[0];
|
||||
private static final String CLASS_RESOURCE_EXTENSION = ".class";
|
||||
private final Map<String, PseudoClass> myLoaded = new HashMap<String, PseudoClass>(); // className -> class object
|
||||
private final ClassFinderClasspath myPlatformClasspath;
|
||||
private final ClassFinderClasspath myClasspath;
|
||||
private final OutputFilesSink myCompiled;
|
||||
|
||||
public InstrumentationClassFinder(final URL[] platformClasspath, final URL[] classpath, OutputFilesSink compiled) {
|
||||
myCompiled = compiled;
|
||||
public InstrumentationClassFinder(final URL[] platformClasspath, final URL[] classpath) {
|
||||
myPlatformClasspath = new ClassFinderClasspath(platformClasspath);
|
||||
myClasspath = new ClassFinderClasspath(classpath);
|
||||
}
|
||||
@@ -53,10 +53,7 @@ class InstrumentationClassFinder {
|
||||
}
|
||||
// second look into memory and classspath
|
||||
if (is == null) {
|
||||
final OutputFileObject.Content content = myCompiled.lookupClassBytes(internalName.replace("/", "."));
|
||||
if (content != null) {
|
||||
is = new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength());
|
||||
}
|
||||
is = lookupClassBeforeClasspath(internalName);
|
||||
}
|
||||
|
||||
if (is == null) {
|
||||
@@ -65,7 +62,11 @@ class InstrumentationClassFinder {
|
||||
is = resource.getInputStream();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is == null) {
|
||||
is = lookupClassAfterClasspath(internalName);
|
||||
}
|
||||
|
||||
if (is == null) {
|
||||
throw new ClassNotFoundException("Class not found: " + internalName);
|
||||
}
|
||||
@@ -80,6 +81,16 @@ class InstrumentationClassFinder {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected InputStream lookupClassBeforeClasspath(final String internalClassName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected InputStream lookupClassAfterClasspath(final String internalClassName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private PseudoClass loadPseudoClass(InputStream is) throws IOException {
|
||||
final ClassReader reader = new ClassReader(is);
|
||||
final V visitor = new V();
|
||||
@@ -194,4 +205,390 @@ class InstrumentationClassFinder {
|
||||
myIsInterface = (access & Opcodes.ACC_INTERFACE) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
static class ClassFinderClasspath {
|
||||
private static final String FILE_PROTOCOL = "file";
|
||||
|
||||
private final Stack<URL> myUrls = new Stack<URL>();
|
||||
private final List<Loader> myLoaders = new ArrayList<Loader>();
|
||||
private final Map<URL,Loader> myLoadersMap = new HashMap<URL, Loader>();
|
||||
|
||||
public ClassFinderClasspath(URL[] urls) {
|
||||
if (urls.length > 0) {
|
||||
for (int i = urls.length - 1; i >= 0; i--) {
|
||||
myUrls.push(urls[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(String s, boolean flag) {
|
||||
int i = 0;
|
||||
for (Loader loader; (loader = getLoader(i)) != null; i++) {
|
||||
Resource resource = loader.getResource(s, flag);
|
||||
if (resource != null) {
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
for (Loader loader : myLoaders) {
|
||||
loader.releaseResources();
|
||||
}
|
||||
myLoaders.clear();
|
||||
myLoadersMap.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private synchronized Loader getLoader(int i) {
|
||||
while (myLoaders.size() < i + 1) {
|
||||
URL url;
|
||||
synchronized (myUrls) {
|
||||
if (myUrls.empty()) {
|
||||
return null;
|
||||
}
|
||||
url = myUrls.pop();
|
||||
}
|
||||
|
||||
if (myLoadersMap.containsKey(url)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Loader loader;
|
||||
try {
|
||||
loader = getLoader(url, myLoaders.size());
|
||||
if (loader == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
myLoaders.add(loader);
|
||||
myLoadersMap.put(url, loader);
|
||||
}
|
||||
|
||||
return myLoaders.get(i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Loader getLoader(final URL url, int index) throws IOException {
|
||||
String s;
|
||||
try {
|
||||
s = url.toURI().getSchemeSpecificPart();
|
||||
}
|
||||
catch (URISyntaxException thisShouldNotHappen) {
|
||||
thisShouldNotHappen.printStackTrace();
|
||||
s = url.getFile();
|
||||
}
|
||||
|
||||
Loader loader = null;
|
||||
if (s != null && new File(s).isDirectory()) {
|
||||
if (FILE_PROTOCOL.equals(url.getProtocol())) {
|
||||
loader = new FileLoader(url, index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
loader = new JarLoader(url, index);
|
||||
}
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
|
||||
private abstract static class Loader {
|
||||
protected static final String JAR_PROTOCOL = "jar";
|
||||
protected static final String FILE_PROTOCOL = "file";
|
||||
|
||||
private final URL myURL;
|
||||
private final int myIndex;
|
||||
|
||||
protected Loader(URL url, int index) {
|
||||
myURL = url;
|
||||
myIndex = index;
|
||||
}
|
||||
|
||||
|
||||
protected URL getBaseURL() {
|
||||
return myURL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract Resource getResource(final String name, boolean flag);
|
||||
|
||||
public abstract void releaseResources();
|
||||
|
||||
public int getIndex() {
|
||||
return myIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileLoader extends Loader {
|
||||
private final File myRootDir;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
FileLoader(URL url, int index) throws IOException {
|
||||
super(url, index);
|
||||
if (!FILE_PROTOCOL.equals(url.getProtocol())) {
|
||||
throw new IllegalArgumentException("url");
|
||||
}
|
||||
else {
|
||||
final String s = unescapePercentSequences(url.getFile().replace('/', File.separatorChar));
|
||||
myRootDir = new File(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(final String name, boolean check) {
|
||||
URL url = null;
|
||||
File file = null;
|
||||
|
||||
try {
|
||||
url = new URL(getBaseURL(), name);
|
||||
if (!url.getFile().startsWith(getBaseURL().getFile())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
file = new File(myRootDir, name.replace('/', File.separatorChar));
|
||||
if (!check || file.exists()) { // check means we load or process resource so we check its existence via old way
|
||||
return new FileResource(name, url, file, !check);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (!check && file != null && file.exists()) {
|
||||
try { // we can not open the file if it is directory, Resource still can be created
|
||||
return new FileResource(name, url, file, false);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class FileResource extends Resource {
|
||||
private final String myName;
|
||||
private final URL myUrl;
|
||||
private final File myFile;
|
||||
|
||||
public FileResource(String name, URL url, File file, boolean willLoadBytes) throws IOException {
|
||||
myName = name;
|
||||
myUrl = url;
|
||||
myFile = file;
|
||||
if (willLoadBytes) getByteBuffer(); // check for existence by creating cached file input stream
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public URL getCodeSourceURL() {
|
||||
return getBaseURL();
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new BufferedInputStream(new FileInputStream(myFile));
|
||||
}
|
||||
|
||||
public int getContentLength() throws IOException {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myFile.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "FileLoader [" + myRootDir + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private class JarLoader extends Loader {
|
||||
private final URL myURL;
|
||||
private ZipFile myZipFile;
|
||||
|
||||
JarLoader(URL url, int index) throws IOException {
|
||||
super(new URL(JAR_PROTOCOL, "", -1, url + "!/"), index);
|
||||
myURL = url;
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
final ZipFile zipFile = myZipFile;
|
||||
if (zipFile != null) {
|
||||
myZipFile = null;
|
||||
try {
|
||||
zipFile.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ZipFile acquireZipFile() throws IOException {
|
||||
ZipFile zipFile = myZipFile;
|
||||
if (zipFile == null) {
|
||||
zipFile = doGetZipFile();
|
||||
myZipFile = zipFile;
|
||||
}
|
||||
return zipFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ZipFile doGetZipFile() throws IOException {
|
||||
if (FILE_PROTOCOL.equals(myURL.getProtocol())) {
|
||||
String s = unescapePercentSequences(myURL.getFile().replace('/', File.separatorChar));
|
||||
if (!new File(s).exists()) {
|
||||
throw new FileNotFoundException(s);
|
||||
}
|
||||
else {
|
||||
return new ZipFile(s);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getResource(String name, boolean flag) {
|
||||
try {
|
||||
final ZipFile file = acquireZipFile();
|
||||
if (file != null) {
|
||||
final ZipEntry entry = file.getEntry(name);
|
||||
if (entry != null) {
|
||||
return new JarResource(entry, new URL(getBaseURL(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class JarResource extends Resource {
|
||||
private final ZipEntry myEntry;
|
||||
private final URL myUrl;
|
||||
|
||||
public JarResource(ZipEntry name, URL url) {
|
||||
myEntry = name;
|
||||
myUrl = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myEntry.getName();
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public URL getCodeSourceURL() {
|
||||
return myURL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream getInputStream() throws IOException {
|
||||
ZipFile file = null;
|
||||
try {
|
||||
file = acquireZipFile();
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final InputStream inputStream = file.getInputStream(myEntry);
|
||||
if (inputStream == null) {
|
||||
return null; // if entry was not found
|
||||
}
|
||||
return new FilterInputStream(inputStream) {};
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getContentLength() {
|
||||
return (int)myEntry.getSize();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "JarLoader [" + myURL + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static String unescapePercentSequences(@NotNull String s) {
|
||||
if (s.indexOf('%') == -1) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder decoded = new StringBuilder();
|
||||
final int len = s.length();
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
char c = s.charAt(i);
|
||||
if (c == '%') {
|
||||
List<Integer> bytes = new ArrayList<Integer>();
|
||||
while (i + 2 < len && s.charAt(i) == '%') {
|
||||
final int d1 = decode(s.charAt(i + 1));
|
||||
final int d2 = decode(s.charAt(i + 2));
|
||||
if (d1 != -1 && d2 != -1) {
|
||||
bytes.add(((d1 & 0xf) << 4 | d2 & 0xf));
|
||||
i += 3;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bytes.isEmpty()) {
|
||||
final byte[] bytesArray = new byte[bytes.size()];
|
||||
for (int j = 0; j < bytes.size(); j++) {
|
||||
bytesArray[j] = (byte)bytes.get(j).intValue();
|
||||
}
|
||||
try {
|
||||
decoded.append(new String(bytesArray, "UTF-8"));
|
||||
continue;
|
||||
}
|
||||
catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decoded.append(c);
|
||||
i++;
|
||||
}
|
||||
return decoded.toString();
|
||||
}
|
||||
|
||||
private static int decode(char c) {
|
||||
if ((c >= '0') && (c <= '9')){
|
||||
return c - '0';
|
||||
}
|
||||
if ((c >= 'a') && (c <= 'f')){
|
||||
return c - 'a' + 10;
|
||||
}
|
||||
if ((c >= 'A') && (c <= 'F')){
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static InstrumentationClassFinder createInstrumentationClassFinder(Collection<File> platformCp,
|
||||
Collection<File> classpath,
|
||||
OutputFilesSink outputSink) throws MalformedURLException {
|
||||
final OutputFilesSink outputSink) throws MalformedURLException {
|
||||
final URL[] platformUrls = new URL[platformCp.size()];
|
||||
int index = 0;
|
||||
for (File file : platformCp) {
|
||||
@@ -544,7 +544,15 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
urls[index++] = getResourcePath(GridConstraints.class).toURI().toURL(); // forms_rt.jar
|
||||
//urls.add(getResourcePath(CellConstraints.class).toURI().toURL()); // jgoodies-forms
|
||||
|
||||
return new InstrumentationClassFinder(platformUrls, urls, outputSink);
|
||||
return new InstrumentationClassFinder(platformUrls, urls) {
|
||||
protected InputStream lookupClassBeforeClasspath(String internalClassName) {
|
||||
final OutputFileObject.Content content = outputSink.lookupClassBytes(internalClassName.replace("/", "."));
|
||||
if (content != null) {
|
||||
return new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static ClassLoader createInstrumentationClassLoader(Collection<File> platformCp, Collection<File> classpath,
|
||||
|
||||
@@ -154,15 +154,28 @@ public class ClasspathBootstrap {
|
||||
if (systemCompiler != null) {
|
||||
try {
|
||||
final String localJarPath = FileUtil.toSystemIndependentName(getResourcePath(systemCompiler.getClass()).getPath());
|
||||
final String localJavaHome = SystemProperties.getJavaHome();
|
||||
String relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(localJavaHome), localJarPath, '/');
|
||||
if (relPath != null) {
|
||||
if (relPath.contains("..")) {
|
||||
relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/');
|
||||
final String localJavaHome = FileUtil.toSystemIndependentName(SystemProperties.getJavaHome());
|
||||
if (FileUtil.pathsEqual(localJavaHome, FileUtil.toSystemIndependentName(sdkHome))) {
|
||||
cp.add(new File(localJarPath));
|
||||
}
|
||||
else {
|
||||
// sdkHome is not the same as the sdk used to run this process
|
||||
final File candidate = new File(sdkHome, "lib/tools.jar");
|
||||
if (candidate.exists()) {
|
||||
cp.add(candidate);
|
||||
}
|
||||
if (relPath != null) {
|
||||
final File targetFile = new File(sdkHome +"/" +relPath);
|
||||
cp.add(targetFile); // tools.jar
|
||||
else {
|
||||
// last resort
|
||||
String relPath = FileUtil.getRelativePath(localJavaHome, localJarPath, '/');
|
||||
if (relPath != null) {
|
||||
if (relPath.contains("..")) {
|
||||
relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/');
|
||||
}
|
||||
if (relPath != null) {
|
||||
final File targetFile = new File(sdkHome, relPath);
|
||||
cp.add(targetFile); // tools.jar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,24 +187,35 @@ public class IconUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static Icon getAddRowIcon() {
|
||||
return SystemInfo.isMac ? PlatformIcons.TABLE_ADD_ROW : PlatformIcons.ADD_ICON;
|
||||
public static Icon getAddIcon() {
|
||||
return getToolbarDecoratorIcon("add.png");
|
||||
}
|
||||
|
||||
public static Icon getRemoveRowIcon() {
|
||||
return SystemInfo.isMac ? PlatformIcons.TABLE_REMOVE_ROW : PlatformIcons.DELETE_ICON;
|
||||
public static Icon getRemoveIcon() {
|
||||
return getToolbarDecoratorIcon("remove.png");
|
||||
}
|
||||
|
||||
public static Icon getMoveRowUpIcon() {
|
||||
return SystemInfo.isMac ? PlatformIcons.TABLE_MOVE_ROW_UP : PlatformIcons.MOVE_UP_ICON;
|
||||
public static Icon getMoveUpIcon() {
|
||||
return getToolbarDecoratorIcon("moveUp.png");
|
||||
}
|
||||
|
||||
public static Icon getMoveRowDownIcon() {
|
||||
return SystemInfo.isMac ? PlatformIcons.TABLE_MOVE_ROW_DOWN : PlatformIcons.MOVE_DOWN_ICON;
|
||||
public static Icon getMoveDownIcon() {
|
||||
return getToolbarDecoratorIcon("moveDown.png");
|
||||
}
|
||||
|
||||
public static Icon getEditIcon() {
|
||||
return SystemInfo.isMac ? PlatformIcons.TABLE_EDIT_ROW : PlatformIcons.EDIT;
|
||||
return getToolbarDecoratorIcon("edit.png");
|
||||
}
|
||||
|
||||
public static Icon getAddClassIcon() {
|
||||
return getToolbarDecoratorIcon("addClass.png");
|
||||
}
|
||||
|
||||
public static Icon getToolbarDecoratorIcon(String name) {
|
||||
return IconLoader.getIcon(getToolbarDecoratorIconsFolder() + name);
|
||||
}
|
||||
|
||||
private static String getToolbarDecoratorIconsFolder() {
|
||||
return "/toolbarDecorator/" + (SystemInfo.isMac ? "mac/" : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 610 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 435 B |
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 236 B |
|
After Width: | Height: | Size: 194 B |
|
After Width: | Height: | Size: 187 B |
|
After Width: | Height: | Size: 171 B |
|
After Width: | Height: | Size: 568 B |
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 585 B |
@@ -98,6 +98,7 @@ public class NanoXmlUtil {
|
||||
}
|
||||
catch (XMLException e) {
|
||||
if (e.getException() instanceof ParserStoppedException) return;
|
||||
if (e.getException() instanceof ParserStoppedXmlException) return;
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
@@ -203,8 +204,8 @@ public class NanoXmlUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static void stop() {
|
||||
throw new ParserStoppedException();
|
||||
protected static void stop() throws ParserStoppedXmlException {
|
||||
throw ParserStoppedXmlException.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,6 +319,22 @@ public class NanoXmlUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ParserStoppedXmlException extends XMLException {
|
||||
public static final ParserStoppedException INSTANCE = new ParserStoppedException();
|
||||
|
||||
private ParserStoppedXmlException() {
|
||||
super("Parsing stopped");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated throw {@link ParserStoppedXmlException#INSTANCE} instead
|
||||
*/
|
||||
public static class ParserStoppedException extends RuntimeException {
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
@@ -338,7 +355,7 @@ public class NanoXmlUtil {
|
||||
public void startElement(final String name, final String nsPrefix, final String nsURI, final String systemID, final int lineNr) throws Exception {
|
||||
myRootTagName = name;
|
||||
myNamespace = nsURI;
|
||||
throw new NanoXmlUtil.ParserStoppedException();
|
||||
throw ParserStoppedXmlException.INSTANCE;
|
||||
}
|
||||
|
||||
public void addAttribute(final String key, final String nsPrefix, final String nsURI, final String value, final String type) throws Exception {
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.codeStyle.*;
|
||||
import com.intellij.ui.components.JBTabbedPane;
|
||||
import com.intellij.ui.TabbedPaneWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
|
||||
private CodeStyleAbstractPanel myActiveTab;
|
||||
private List<CodeStyleAbstractPanel> myTabs;
|
||||
private JPanel myPanel;
|
||||
private JTabbedPane myTabbedPane;
|
||||
private TabbedPaneWrapper myTabbedPane;
|
||||
private PredefinedCodeStyle[] myPredefinedCodeStyles;
|
||||
private JPopupMenu myCopyFromMenu;
|
||||
|
||||
@@ -113,9 +113,9 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
|
||||
if (myTabs == null) {
|
||||
myPanel = new JPanel();
|
||||
myPanel.setLayout(new BorderLayout());
|
||||
myTabbedPane = new JBTabbedPane();
|
||||
myTabbedPane = new TabbedPaneWrapper(this);
|
||||
myTabs = new ArrayList<CodeStyleAbstractPanel>();
|
||||
myPanel.add(myTabbedPane);
|
||||
myPanel.add(myTabbedPane.getComponent());
|
||||
initTabs(getSettings());
|
||||
}
|
||||
assert !myTabs.isEmpty();
|
||||
|
||||
@@ -345,7 +345,9 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
}
|
||||
|
||||
public int getSeverityIdx(@NotNull HighlightSeverity severity) {
|
||||
return getOrder().get(severity);
|
||||
final OrderMap order = getOrder();
|
||||
if (!order.contains(severity)) return -1;
|
||||
return order.get(severity);
|
||||
}
|
||||
|
||||
public boolean isDefaultSeverity(@NotNull HighlightSeverity severity) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public interface MultiCharQuoteHandler extends QuoteHandler {
|
||||
/**
|
||||
* returns closing quote by opening quote which is placed immediately before offset. If there is no quote or the quote is equivalent
|
||||
* to opening quote the method should return null
|
||||
*/
|
||||
@Nullable
|
||||
CharSequence getClosingQuote(HighlighterIterator iterator, int offset);
|
||||
}
|
||||
@@ -42,9 +42,9 @@ import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -205,7 +205,7 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
|
||||
if (!editor.getSelectionModel().hasBlockSelection()) {
|
||||
if (')' == charTyped || ']' == charTyped || '}' == charTyped) {
|
||||
if (StdFileTypes.PLAIN_TEXT != fileType) {
|
||||
if (FileTypes.PLAIN_TEXT != fileType) {
|
||||
if (handleRParen(editor, fileType, charTyped)) return;
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
|
||||
if (('(' == charTyped || '[' == charTyped || '{' == charTyped) &&
|
||||
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET &&
|
||||
!editor.getSelectionModel().hasBlockSelection() && fileType != StdFileTypes.PLAIN_TEXT) {
|
||||
!editor.getSelectionModel().hasBlockSelection() && fileType != FileTypes.PLAIN_TEXT) {
|
||||
handleAfterLParen(editor, fileType, charTyped);
|
||||
}
|
||||
else if ('}' == charTyped) {
|
||||
@@ -436,8 +436,18 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
myOriginalHandler.execute(editor, quote, dataContext);
|
||||
offset = editor.getCaretModel().getOffset();
|
||||
|
||||
if (isOpeningQuote(editor, quoteHandler, offset - 1) &&
|
||||
hasNonClosedLiterals(editor, quoteHandler, offset - 1)) {
|
||||
if (quoteHandler instanceof MultiCharQuoteHandler) {
|
||||
CharSequence closingQuote = getClosingQuote(editor, (MultiCharQuoteHandler)quoteHandler, offset);
|
||||
if (closingQuote != null && hasNonClosedLiterals(editor, quoteHandler, offset - 1)) {
|
||||
if (offset == document.getTextLength() ||
|
||||
!Character.isUnicodeIdentifierPart(document.getCharsSequence().charAt(offset))) { //any better heuristic or an API?
|
||||
document.insertString(offset, closingQuote);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isOpeningQuote(editor, quoteHandler, offset - 1) && hasNonClosedLiterals(editor, quoteHandler, offset - 1)) {
|
||||
if (offset == document.getTextLength() ||
|
||||
!Character.isUnicodeIdentifierPart(document.getCharsSequence().charAt(offset))) { //any better heuristic or an API?
|
||||
document.insertString(offset, String.valueOf(quote));
|
||||
@@ -457,6 +467,17 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
return quoteHandler.isClosingQuote(iterator,offset);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CharSequence getClosingQuote(Editor editor, MultiCharQuoteHandler quoteHandler, int offset) {
|
||||
HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(offset);
|
||||
if (iterator.atEnd()){
|
||||
LOG.assertTrue(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
return quoteHandler.getClosingQuote(iterator, offset);
|
||||
}
|
||||
|
||||
private static boolean isOpeningQuote(Editor editor, QuoteHandler quoteHandler, int offset) {
|
||||
HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(offset);
|
||||
if (iterator.atEnd()){
|
||||
|
||||
@@ -335,13 +335,16 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
public void run(final @NotNull ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
myElements =
|
||||
getSelfAndImplementations(myEditor, myElement, new ImplementationSearcher.BackgroundableImplementationSearcher() {
|
||||
@Override
|
||||
protected void processElement(PsiElement element) {
|
||||
updateComponent(element, null);
|
||||
if (!updateComponent(element, null)) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -83,12 +83,12 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
public void updateComponent(PsiElement element, @Nullable final Comparator comparator) {
|
||||
if (myCanceled) return;
|
||||
if (myPopup.isDisposed()) return;
|
||||
public boolean updateComponent(PsiElement element, @Nullable final Comparator comparator) {
|
||||
if (myCanceled) return false;
|
||||
if (myPopup.isDisposed()) return false;
|
||||
|
||||
synchronized (lock) {
|
||||
if (myData.contains(element)) return;
|
||||
if (myData.contains(element)) return true;
|
||||
myData.add(element);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
myPopup.pack(true, true);
|
||||
}
|
||||
}, 200, ModalityState.stateForComponent(myPopup.getContent()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCurrentSize() {
|
||||
|
||||
@@ -78,16 +78,21 @@ public class GotoImplementationHandler extends GotoTargetHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
public void run(final @NotNull ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
for (PsiElement element : myGotoData.targets) {
|
||||
updateComponent(element, createComparator(renderers, myGotoData));
|
||||
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
new ImplementationSearcher.BackgroundableImplementationSearcher() {
|
||||
protected void processElement(PsiElement element) {
|
||||
if (myGotoData.addTarget(element)) {
|
||||
updateComponent(element, createComparator(renderers, myGotoData));
|
||||
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
|
||||
indicator.cancel();
|
||||
}
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
}.searchImplementations(myEditor, myGotoData.source, myOffset);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.analysis.AnalysisScopeBundle;
|
||||
import com.intellij.analysis.AnalysisUIOptions;
|
||||
import com.intellij.analysis.BaseAnalysisActionDialog;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
|
||||
@@ -41,6 +42,7 @@ import com.intellij.psi.search.PsiSearchScopeUtil;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
@@ -62,8 +64,7 @@ public class RunInspectionAction extends GotoActionBase {
|
||||
|
||||
final PsiElement psiElement = LangDataKeys.PSI_ELEMENT.getData(e.getDataContext());
|
||||
final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
|
||||
final VirtualFile virtualFile = LangDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
|
||||
if (virtualFile == null) return;
|
||||
final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
|
||||
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.inspection");
|
||||
|
||||
@@ -84,24 +85,27 @@ public class RunInspectionAction extends GotoActionBase {
|
||||
|
||||
private static void runInspection(@NotNull Project project,
|
||||
@NotNull InspectionProfileEntry profileEntry,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@Nullable VirtualFile virtualFile,
|
||||
PsiElement psiElement, PsiFile psiFile) {
|
||||
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManagerEx.getInstance(project);
|
||||
final Module module = ModuleUtil.findModuleForFile(virtualFile, project);
|
||||
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
|
||||
final Module module = virtualFile != null ? ModuleUtil.findModuleForFile(virtualFile, project) : null;
|
||||
|
||||
AnalysisScope analysisScope = null;
|
||||
if (psiFile != null) {
|
||||
analysisScope = new AnalysisScope(psiFile);
|
||||
} else {
|
||||
if (virtualFile.isDirectory()) {
|
||||
if (virtualFile != null && virtualFile.isDirectory()) {
|
||||
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
|
||||
if (psiDirectory != null) {
|
||||
analysisScope = new AnalysisScope(psiDirectory);
|
||||
}
|
||||
}
|
||||
if (analysisScope == null) {
|
||||
if (analysisScope == null && virtualFile != null) {
|
||||
analysisScope = new AnalysisScope(project, Arrays.asList(virtualFile));
|
||||
}
|
||||
if (analysisScope == null) {
|
||||
analysisScope = new AnalysisScope(project);
|
||||
}
|
||||
}
|
||||
|
||||
final FileFilterPanel fileFilterPanel = new FileFilterPanel();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.codeInspection.ui.InspectionResultsView;
|
||||
import com.intellij.concurrency.JobUtil;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
@@ -42,7 +43,7 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -59,6 +60,7 @@ import com.intellij.ui.content.*;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.TripleFunction;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Document;
|
||||
@@ -67,7 +69,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -201,12 +202,9 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
});
|
||||
|
||||
myView = view;
|
||||
ContentManager contentManager = getContentManager();
|
||||
myContent = ContentFactory.SERVICE.getInstance().createContent(view, title, false);
|
||||
|
||||
myContent.setDisposer(myView);
|
||||
contentManager.addContent(myContent);
|
||||
contentManager.setSelectedContent(myContent);
|
||||
|
||||
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.INSPECTION).activate(null);
|
||||
}
|
||||
@@ -423,14 +421,14 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
LOG.info("Code inspection finished");
|
||||
|
||||
if (myView != null) {
|
||||
if (!myView.update() && !getUIOptions().SHOW_ONLY_DIFF) {
|
||||
Messages.showMessageDialog(myProject, InspectionsBundle.message("inspection.no.problems.message"),
|
||||
InspectionsBundle.message("inspection.no.problems.dialog.title"), Messages.getInformationIcon());
|
||||
NotificationGroup.toolWindowGroup("Inspection Results", ToolWindowId.INSPECTION, true)
|
||||
.createNotification(InspectionsBundle.message("inspection.no.problems.message"), MessageType.INFO).notify(myProject);
|
||||
close(true);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -426,11 +426,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
public void disableToolByDefault(String toolId) {
|
||||
getTools(toolId).getDefaultState().setEnabled(false);
|
||||
getToolDefaultState(toolId).setEnabled(false);
|
||||
}
|
||||
|
||||
public ScopeToolState getToolDefaultState(String toolId) {
|
||||
return getTools(toolId).getDefaultState();
|
||||
}
|
||||
|
||||
public void enableToolByDefault(String toolId) {
|
||||
getTools(toolId).getDefaultState().setEnabled(true);
|
||||
getToolDefaultState(toolId).setEnabled(true);
|
||||
}
|
||||
|
||||
public boolean wasInitialized() {
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ProblemDescriptionNode extends InspectionTreeNode {
|
||||
if (descriptor == null) return "";
|
||||
PsiElement element = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
|
||||
|
||||
return renderDescriptionMessage(descriptor, element, true).replaceAll("<[^>]*>", "");
|
||||
return renderDescriptionMessage(descriptor, element, true)/*.replaceAll("<[^>]*>", "")*/;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -181,7 +181,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
|
||||
.disableUpAction()
|
||||
.addExtraAction(new DeleteFromFavoritesAction() {
|
||||
{
|
||||
getTemplatePresentation().setIcon(IconUtil.getRemoveRowIcon());
|
||||
getTemplatePresentation().setIcon(IconUtil.getRemoveIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,7 +82,15 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
@NonNls private static final String ROOT_ELEMENT = "root";
|
||||
private final ProjectRootManagerImpl myProjectRootManager;
|
||||
// have to register all child disposables using this fake object since all clients call just ModifiableModel.dispose()
|
||||
private final Disposable myDisposable = Disposer.newDisposable();
|
||||
private final List<Disposable> myModelComponents = Collections.synchronizedList(new ArrayList<Disposable>());
|
||||
private final Disposable myDisposable = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
for (Disposable component : myModelComponents) {
|
||||
Disposer.dispose(component);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RootModelImpl(@NotNull ModuleRootManagerImpl moduleRootManager, ProjectRootManagerImpl projectRootManager, VirtualFilePointerManager filePointerManager) {
|
||||
myModuleRootManager = moduleRootManager;
|
||||
@@ -96,7 +104,7 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
|
||||
for (ModuleExtension extension : Extensions.getExtensions(ModuleExtension.EP_NAME, moduleRootManager.getModule())) {
|
||||
ModuleExtension model = extension.getModifiableModel(false);
|
||||
Disposer.register(myDisposable, model);
|
||||
registerOnDispose(model);
|
||||
myExtensions.add(model);
|
||||
}
|
||||
myConfigurationAccessor = new RootConfigurationAccessor();
|
||||
@@ -162,7 +170,7 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
for (ModuleExtension extension : originalRootModel.myExtensions) {
|
||||
ModuleExtension model = extension.getModifiableModel(false);
|
||||
model.readExternal(element);
|
||||
Disposer.register(myDisposable, model);
|
||||
registerOnDispose(model);
|
||||
myExtensions.add(model);
|
||||
}
|
||||
myConfigurationAccessor = new RootConfigurationAccessor();
|
||||
@@ -207,7 +215,7 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
|
||||
for (ModuleExtension extension : rootModel.myExtensions) {
|
||||
ModuleExtension model = extension.getModifiableModel(writable);
|
||||
Disposer.register(myDisposable, model);
|
||||
registerOnDispose(model);
|
||||
myExtensions.add(model);
|
||||
}
|
||||
}
|
||||
@@ -912,6 +920,7 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
myExtensions.clear();
|
||||
myWritable = false;
|
||||
myDisposed = true;
|
||||
myModelComponents.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1139,6 +1148,6 @@ public class RootModelImpl implements ModifiableRootModel {
|
||||
}
|
||||
|
||||
void registerOnDispose(@NotNull Disposable disposable) {
|
||||
Disposer.register(myDisposable, disposable);
|
||||
myModelComponents.add(disposable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,29 +1048,13 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
for (int i = 0; rows != null && i < rows.length; i++) {
|
||||
final InspectionConfigTreeNode node = (InspectionConfigTreeNode)myTree.getPathForRow(rows[i]).getLastPathComponent();
|
||||
final InspectionConfigTreeNode parent = (InspectionConfigTreeNode)node.getParent();
|
||||
if (node.getUserObject() instanceof Descriptor) {
|
||||
final Object userObject = node.getUserObject();
|
||||
if (userObject instanceof Descriptor && (node.getScopeName() != null || node.isLeaf())) {
|
||||
updateErrorLevel(node, showOptionsAndDescriptorPanels, level);
|
||||
updateUpHierarchy(node, parent);
|
||||
}
|
||||
else {
|
||||
node.isProperSetting = false;
|
||||
for (int j = 0; j < node.getChildCount(); j++) {
|
||||
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
|
||||
if (child.getUserObject() instanceof Descriptor) { //group node
|
||||
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
else { //root node
|
||||
child.isProperSetting = false;
|
||||
for (int k = 0; k < child.getChildCount(); k++) {
|
||||
final InspectionConfigTreeNode descriptorNode = (InspectionConfigTreeNode)child.getChildAt(k);
|
||||
if (descriptorNode.getUserObject() instanceof Descriptor) {
|
||||
updateErrorLevel(descriptorNode, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
child.isProperSetting |= descriptorNode.isProperSetting;
|
||||
}
|
||||
}
|
||||
node.isProperSetting |= child.isProperSetting;
|
||||
}
|
||||
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node);
|
||||
updateUpHierarchy(node, parent);
|
||||
}
|
||||
}
|
||||
@@ -1083,6 +1067,23 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
repaintTableData();
|
||||
}
|
||||
|
||||
private void updateErrorLevelUpInHierarchy(HighlightDisplayLevel level,
|
||||
boolean showOptionsAndDescriptorPanels,
|
||||
InspectionConfigTreeNode node) {
|
||||
node.isProperSetting = false;
|
||||
for (int j = 0; j < node.getChildCount(); j++) {
|
||||
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
|
||||
final Object userObject = child.getUserObject();
|
||||
if (userObject instanceof Descriptor && (child.getScopeName() != null || child.isLeaf())) {
|
||||
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
else {
|
||||
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, child);
|
||||
}
|
||||
node.isProperSetting |= child.isProperSetting;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateErrorLevel(final InspectionConfigTreeNode child,
|
||||
final boolean showOptionsAndDescriptorPanels, final HighlightDisplayLevel level) {
|
||||
final HighlightDisplayKey key = child.getDesriptor().getKey();
|
||||
|
||||
@@ -59,13 +59,11 @@ public abstract class AddScopeAction extends AnAction {
|
||||
if (getSelectedProfile() == null) return;
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) return;
|
||||
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
if (selectedNodes == null) return;
|
||||
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
for (InspectionConfigTreeNode node : nodes) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (descriptor != null && node.getScopeName() == null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
for (InspectionConfigTreeNode node : selectedNodes) {
|
||||
collect(descriptors, new ArrayList<InspectionConfigTreeNode>(), node);
|
||||
}
|
||||
|
||||
presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty());
|
||||
@@ -73,13 +71,13 @@ public abstract class AddScopeAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
for (InspectionConfigTreeNode node : nodes) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (node.getScopeName() == null && descriptor != null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
LOG.assertTrue(selectedNodes != null);
|
||||
|
||||
final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>(Arrays.asList(selectedNodes));
|
||||
for (InspectionConfigTreeNode node : selectedNodes) {
|
||||
collect(descriptors, nodes, node);
|
||||
}
|
||||
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
@@ -97,7 +95,7 @@ public abstract class AddScopeAction extends AnAction {
|
||||
getSelectedProfile().isToolEnabled(descriptor.getKey()));
|
||||
final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile());
|
||||
if (node.getChildCount() == 0) {
|
||||
node.add(new InspectionConfigTreeNode(descriptor, scopeToolState, true, true, false));
|
||||
node.add(new InspectionConfigTreeNode(descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().getID()), true, true, false));
|
||||
}
|
||||
node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, true, false), 0);
|
||||
node.setInspectionNode(false);
|
||||
@@ -108,6 +106,23 @@ public abstract class AddScopeAction extends AnAction {
|
||||
myTree.revalidate();
|
||||
}
|
||||
|
||||
private static void collect(List<Descriptor> descriptors,
|
||||
List<InspectionConfigTreeNode> nodes,
|
||||
InspectionConfigTreeNode node) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (descriptor != null) {
|
||||
if (node.getScopeName() == null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
} else if (node.getUserObject() instanceof String) {
|
||||
for(int i = 0; i < node.getChildCount(); i++) {
|
||||
final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i);
|
||||
nodes.add(childNode);
|
||||
collect(descriptors, nodes, childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) {
|
||||
final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
|
||||
for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
|
||||
|
||||
@@ -53,7 +53,6 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class AbstractTreeUi {
|
||||
@@ -177,8 +176,7 @@ public class AbstractTreeUi {
|
||||
private SimpleTimerTask myCleanupTask;
|
||||
|
||||
private final AtomicBoolean myCancelRequest = new AtomicBoolean();
|
||||
private final Lock myStateLock = new ReentrantLock();
|
||||
private final AtomicBoolean myLockWasAcquired = new AtomicBoolean();
|
||||
private final ReentrantLock myStateLock = new ReentrantLock();
|
||||
|
||||
private final AtomicBoolean myResettingToReadyNow = new AtomicBoolean();
|
||||
|
||||
@@ -1923,7 +1921,7 @@ public class AbstractTreeUi {
|
||||
|
||||
@Nullable
|
||||
public Boolean _isReady(boolean attempt) {
|
||||
if (attempt && myLockWasAcquired.get()) return false;
|
||||
if (attempt && myStateLock.isLocked()) return false;
|
||||
|
||||
Boolean ready = checkValue(new Computable<Boolean>() {
|
||||
@Override
|
||||
@@ -2414,21 +2412,17 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
private boolean attemptLock() throws InterruptedException {
|
||||
myLockWasAcquired.set(myStateLock.tryLock(Registry.intValue("ide.tree.uiLockAttempt"), TimeUnit.MILLISECONDS));
|
||||
return myLockWasAcquired.get();
|
||||
return myStateLock.tryLock(Registry.intValue("ide.tree.uiLockAttempt"), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private void acquireLock() {
|
||||
myStateLock.lock();
|
||||
myLockWasAcquired.set(true);
|
||||
}
|
||||
|
||||
private void releaseLock() {
|
||||
myStateLock.unlock();
|
||||
myLockWasAcquired.set(false);
|
||||
}
|
||||
|
||||
|
||||
public ActionCallback batch(final Progressive progressive) {
|
||||
assertIsDispatchThread();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -38,11 +38,11 @@ public class CommonActionsPanel extends JPanel {
|
||||
|
||||
Icon getIcon() {
|
||||
switch (this) {
|
||||
case ADD: return IconUtil.getAddRowIcon();
|
||||
case ADD: return IconUtil.getAddIcon();
|
||||
case EDIT: return IconUtil.getEditIcon();
|
||||
case REMOVE: return IconUtil.getRemoveRowIcon();
|
||||
case UP: return IconUtil.getMoveRowUpIcon();
|
||||
case DOWN: return IconUtil.getMoveRowDownIcon();
|
||||
case REMOVE: return IconUtil.getRemoveIcon();
|
||||
case UP: return IconUtil.getMoveUpIcon();
|
||||
case DOWN: return IconUtil.getMoveDownIcon();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.awt.event.IgnorePaintEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.ComboPopup;
|
||||
@@ -52,14 +51,10 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.awt.event.WindowEvent.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper;
|
||||
import com.intellij.ide.passwordSafe.impl.providers.EncryptionUtil;
|
||||
import com.intellij.ide.passwordSafe.impl.providers.masterKey.windows.WindowsCryptUtils;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
@@ -182,7 +182,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
|
||||
}
|
||||
if (key.get() == null) {
|
||||
final Ref<PasswordSafeException> ex = new Ref<PasswordSafeException>();
|
||||
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(new Runnable() {
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (key.get() == null) {
|
||||
try {
|
||||
@@ -207,7 +207,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, ModalityState.NON_MODAL);
|
||||
//noinspection ThrowableResultOfMethodCallIgnored
|
||||
if (ex.get() != null) {
|
||||
throw ex.get();
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.intellij.ide.passwordSafe.ui;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafeException;
|
||||
import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -271,7 +273,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
final AtomicReference<String> pw = new AtomicReference<String>(null);
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
final PasswordSafePromptDialog d = new PasswordSafePromptDialog(project, ps, title, message);
|
||||
if (promptLabel != null) {
|
||||
@@ -299,7 +301,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, ModalityState.NON_MODAL);
|
||||
return pw.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 com.intellij.internal.tree;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ExpandAll extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Component c = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
|
||||
if (c != null) {
|
||||
final JTree tree = UIUtil.getParentOfType(JTree.class, c);
|
||||
if (tree != null) {
|
||||
TreeUtil.expandAll(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -202,7 +202,7 @@ public abstract class ValidatingTableEditor<Item> implements ComponentWithEmptyT
|
||||
});
|
||||
|
||||
|
||||
myRemoveButton = new AnActionButton(ApplicationBundle.message("button.remove"), IconUtil.getRemoveRowIcon()) {
|
||||
myRemoveButton = new AnActionButton(ApplicationBundle.message("button.remove"), IconUtil.getRemoveIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
removeSelected();
|
||||
|
||||
@@ -526,6 +526,7 @@
|
||||
<action id="UiInspector" internal="true" class="com.intellij.internal.inspector.UiInspectorAction" text="UI Inspector"/>
|
||||
<action id="ShowSplash" internal="true" class="com.intellij.ui.ShowSplashAction" text="Show Splash" />
|
||||
<action id="ValidationTest" internal="true" class="com.intellij.internal.validation.TestDialogWithValidationAction" text="Validation Dialog Test" />
|
||||
<action id="TreeExpandAll" internal="true" class="com.intellij.internal.tree.ExpandAll" text="Expand Tree" />
|
||||
<separator/>
|
||||
<reference ref="MaintenanceGroup"/>
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.vcs.changes.BackgroundFromStartOption;
|
||||
import com.intellij.openapi.vcs.history.ShortVcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,11 +56,16 @@ public class ShowAllAffectedGenericAction extends AnAction {
|
||||
final VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
|
||||
VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
|
||||
if ((revision != null) && (revisionVirtualFile != null)) {
|
||||
showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey);
|
||||
showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey, revision.getChangedRepositoryPath());
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, final VcsKey vcsKey) {
|
||||
showSubmittedFiles(project, revision, virtualFile, vcsKey, null);
|
||||
}
|
||||
|
||||
private static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile,
|
||||
final VcsKey vcsKey, final RepositoryLocation location) {
|
||||
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
|
||||
if (vcs == null) return;
|
||||
if (! isInLocalFSHack(virtualFile) && ! canPresentNonLocal(project, vcsKey, virtualFile)) return;
|
||||
@@ -81,12 +87,29 @@ public class ShowAllAffectedGenericAction extends AnAction {
|
||||
list[0] = pair.getFirst();
|
||||
}
|
||||
} else {
|
||||
final RepositoryLocation local = provider.getForNonLocal(virtualFile);
|
||||
if (local != null) {
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(provider.createDefaultSettings(), local, 1);
|
||||
if (location != null) {
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
settings.USE_CHANGE_BEFORE_FILTER = true;
|
||||
settings.CHANGE_BEFORE = revision.asString();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
|
||||
if (changes != null && changes.size() == 1) {
|
||||
list[0] = changes.get(0);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
final RepositoryLocation local = provider.getForNonLocal(virtualFile);
|
||||
if (local != null) {
|
||||
final String number = revision.asString();
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
|
||||
if (changes != null) {
|
||||
for (CommittedChangeList change : changes) {
|
||||
if (number.equals(String.valueOf(change.getNumber()))) {
|
||||
list[0] = change;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.history;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -82,4 +83,9 @@ public class CurrentRevision implements VcsFileRevision {
|
||||
public String getBranchName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null; // use initial url..
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.history;
|
||||
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
@@ -43,6 +44,11 @@ public interface VcsFileRevision extends VcsFileContent, VcsRevisionDescription
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] loadContent() throws IOException, VcsException {
|
||||
return getContent();
|
||||
}
|
||||
@@ -57,4 +63,6 @@ public interface VcsFileRevision extends VcsFileContent, VcsRevisionDescription
|
||||
};
|
||||
|
||||
String getBranchName();
|
||||
|
||||
RepositoryLocation getChangedRepositoryPath();
|
||||
}
|
||||
|
||||
@@ -29,5 +29,4 @@ public abstract class VcsFileRevisionEx implements VcsFileRevision {
|
||||
|
||||
@Nullable
|
||||
public abstract String getCommitterEmail();
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,15 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
|
||||
myDescription = description;
|
||||
myIcon = icon;
|
||||
myField = new JTextField(initSize);
|
||||
myField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if ('\n' == e.getKeyChar()) {
|
||||
e.consume();
|
||||
actionPerformed(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JComponent createCustomComponent(Presentation presentation) {
|
||||
@@ -66,29 +75,6 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
|
||||
actionPerformed(null);
|
||||
}
|
||||
});
|
||||
/*myField.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
actionPerformed(null);
|
||||
}
|
||||
});*/
|
||||
myField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
reaction(e);
|
||||
}
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
reaction(e);
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void reaction(KeyEvent e) {
|
||||
if ((KeyEvent.VK_ENTER == e.getKeyCode()) || ('\n' == e.getKeyChar())) {
|
||||
e.consume();
|
||||
actionPerformed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,10 @@ public class DuringChangeListManagerUpdateTestScheme {
|
||||
}
|
||||
|
||||
public static void checkFilesAreInList(final VirtualFile[] files, final String listName, final ChangeListManager manager) {
|
||||
checkFilesAreInList(listName, manager, files);
|
||||
}
|
||||
|
||||
public static void checkFilesAreInList(final String listName, final ChangeListManager manager, final VirtualFile... files) {
|
||||
System.out.println("Checking files for list: " + listName);
|
||||
assert manager.findChangeList(listName) != null;
|
||||
final LocalChangeList list = manager.findChangeList(listName);
|
||||
|
||||
@@ -268,6 +268,10 @@ public class ChangesBrowser extends JPanel implements TypeSafeDataProvider {
|
||||
myViewer.setChangesToDisplay(getCurrentDisplayedChanges(), myToSelect);
|
||||
}
|
||||
|
||||
public void setAlwayExpandList(final boolean value) {
|
||||
myViewer.setAlwaysExpandList(value);
|
||||
}
|
||||
|
||||
private JComponent createToolbar() {
|
||||
DefaultActionGroup toolbarGroups = new DefaultActionGroup();
|
||||
myToolBarGroup = new DefaultActionGroup();
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -74,6 +75,7 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
|
||||
private final Collection<T> myIncludedChanges;
|
||||
private Runnable myDoubleClickHandler = EmptyRunnable.getInstance();
|
||||
private boolean myAlwaysExpandList;
|
||||
|
||||
@NonNls private static final String TREE_CARD = "Tree";
|
||||
@NonNls private static final String LIST_CARD = "List";
|
||||
@@ -94,6 +96,7 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
myInclusionListener = inclusionListener;
|
||||
myChangeDecorator = decorator;
|
||||
myIncludedChanges = new HashSet<T>(initiallyIncluded);
|
||||
myAlwaysExpandList = true;
|
||||
|
||||
myCards = new CardLayout();
|
||||
|
||||
@@ -311,21 +314,24 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
return sortedChanges.get(index);
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < sortedChanges.size(); i++) {
|
||||
T t = sortedChanges.get(i);
|
||||
if (wasSelected.contains(t)) {
|
||||
myList.setSelectedIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
final DefaultTreeModel model = buildTreeModel(changes, myChangeDecorator);
|
||||
TreeState state = null;
|
||||
if (! wasEmpty) {
|
||||
if (! myAlwaysExpandList && ! wasEmpty) {
|
||||
state = TreeState.createOn(myTree, (DefaultMutableTreeNode) myTree.getModel().getRoot());
|
||||
}
|
||||
myTree.setModel(model);
|
||||
if (! wasEmpty) {
|
||||
if (! myAlwaysExpandList && ! wasEmpty) {
|
||||
state.applyTo(myTree, (DefaultMutableTreeNode) myTree.getModel().getRoot());
|
||||
|
||||
final TIntArrayList indices = new TIntArrayList();
|
||||
for (int i = 0; i < sortedChanges.size(); i++) {
|
||||
T t = sortedChanges.get(i);
|
||||
if (wasSelected.contains(t)) {
|
||||
indices.add(i);
|
||||
}
|
||||
}
|
||||
myList.setSelectedIndices(indices.toNativeArray());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -857,4 +863,8 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
public void enableSelection(final boolean value) {
|
||||
myTree.setEnabled(value);
|
||||
}
|
||||
|
||||
public void setAlwaysExpandList(boolean alwaysExpandList) {
|
||||
myAlwaysExpandList = alwaysExpandList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
}
|
||||
};
|
||||
myBrowser = browser;
|
||||
myBrowser.setAlwayExpandList(false);
|
||||
myBrowserExtender = browser.getExtender();
|
||||
}
|
||||
myDiffDetails.setParent(myBrowser);
|
||||
|
||||
@@ -1337,6 +1337,11 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return myRevision.getChangedRepositoryPath();
|
||||
}
|
||||
|
||||
public VcsFileRevision getRevision() {
|
||||
return myRevision;
|
||||
}
|
||||
|
||||
@@ -1879,8 +1879,8 @@ unqualified.inner.class.access.option=Ignore references to local inner classes
|
||||
try.with.identical.catches.quickfix=Collapse catch blocks into multi-catch
|
||||
confusing.else.option=<html>Also report when there are no more statements after the 'if' statement</html>
|
||||
html.tag.can.be.javadoc.tag.display.name=<code>...</code> can be replaced with {@code ...}
|
||||
html.tag.can.be.javadoc.tag.problem.descriptor1=<code>#ref...</code></code> can be replaced with '{@code ...}' #loc
|
||||
html.tag.can.be.javadoc.tag.problem.descriptor2=<code><code>...#ref</code> can be replaced with '{@code ...}' #loc
|
||||
html.tag.can.be.javadoc.tag.problem.descriptor1=<code>#ref...\\</code\\></code> can be replaced with '{@code ...}' #loc
|
||||
html.tag.can.be.javadoc.tag.problem.descriptor2=<code>\\<code\\>...#ref</code> can be replaced with '{@code ...}' #loc
|
||||
html.tag.can.be.javadoc.tag.quickfix=Replace with '{@code ...}'
|
||||
try.finally.can.be.try.with.resources.display.name='try finally' replaceable with 'try' with resources
|
||||
try.finally.can.be.try.with.resources.problem.descriptor=<code>#ref</code> can use automatic resource management #loc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -477,7 +477,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
|
||||
private class MyAddFilterAction extends AnAction {
|
||||
private MyAddFilterAction() {
|
||||
super(CommonBundle.message("button.add"), AndroidBundle.message("android.logcat.add.logcat.filter.button"), IconUtil.getAddRowIcon());
|
||||
super(CommonBundle.message("button.add"), AndroidBundle.message("android.logcat.add.logcat.filter.button"), IconUtil.getAddIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -503,7 +503,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
private class MyRemoveFilterAction extends AnAction {
|
||||
private MyRemoveFilterAction() {
|
||||
super(CommonBundle.message("button.delete"), AndroidBundle.message("android.logcat.remove.logcat.filter.button"),
|
||||
IconUtil.getRemoveRowIcon());
|
||||
IconUtil.getRemoveIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.android.uipreview;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -72,7 +87,7 @@ public class LayoutDeviceConfigurationsDialog extends DialogWrapper {
|
||||
|
||||
AnActionButton addButton =
|
||||
new AnActionButton(AndroidBundle.message("android.layout.preview.device.configurations.dialog.add.button"), null,
|
||||
IconUtil.getAddRowIcon()) {
|
||||
IconUtil.getAddIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
doAdd();
|
||||
@@ -90,7 +105,7 @@ public class LayoutDeviceConfigurationsDialog extends DialogWrapper {
|
||||
myEditButton.setShortcut(CustomShortcutSet.fromString("alt E"));
|
||||
|
||||
myRemoveButton = new AnActionButton(AndroidBundle.message("android.layout.preview.device.configurations.dialog.remove.button"), null,
|
||||
IconUtil.getRemoveRowIcon()) {
|
||||
IconUtil.getRemoveIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
doRemove();
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.cvsSupport2.history.CvsRevisionNumber;
|
||||
import com.intellij.openapi.cvsIntegration.CvsResult;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
|
||||
@@ -190,6 +191,11 @@ public class CvsAnnotationProvider implements AnnotationProvider{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] loadContent() throws IOException, VcsException {
|
||||
return getContent();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.cvsIntegration.CvsResult;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
@@ -102,4 +103,8 @@ public class ComparableVcsRevisionOnOperation implements VcsFileRevision {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation
|
||||
import com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import org.netbeans.lib.cvsclient.command.log.LogInformation;
|
||||
import org.netbeans.lib.cvsclient.command.log.Revision;
|
||||
@@ -124,6 +125,11 @@ public class CvsFileRevisionImpl extends CvsFileContent implements CvsFileRevisi
|
||||
return myCvsRevision.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<String> getTags() {
|
||||
if (myTags == null) {
|
||||
myTags = myLogInformation == null ? Collections.<String>emptyList() : collectSymNamesForRevision();
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevisionDvcsSpecific;
|
||||
@@ -79,6 +80,11 @@ public class GitFileRevision extends VcsFileRevisionEx implements Comparable<Vcs
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public VcsRevisionNumber getRevisionNumber() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
@@ -144,22 +144,21 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
|
||||
// note: we are not calling this method during the project startup - it is called anyway by the GitRootTracker
|
||||
private void updateRepositoriesCollection() {
|
||||
try {
|
||||
REPO_LOCK.writeLock().lock();
|
||||
Map<VirtualFile, GitRepository> repositories = new HashMap<VirtualFile, GitRepository>(myRepositories);
|
||||
final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(myVcs);
|
||||
// remove repositories that are not in the roots anymore
|
||||
for (Iterator<Map.Entry<VirtualFile, GitRepository>> iterator = myRepositories.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
for (Iterator<Map.Entry<VirtualFile, GitRepository>> iterator = repositories.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
if (!ArrayUtil.contains(iterator.next().getValue().getRoot(), roots)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
// add GitRepositories for all roots that don't have correspondent GitRepositories yet.
|
||||
for (VirtualFile root : roots) {
|
||||
if (!myRepositories.containsKey(root)) {
|
||||
if (!repositories.containsKey(root)) {
|
||||
if (gitRootOK(root)) {
|
||||
try {
|
||||
GitRepository repository = createGitRepository(root);
|
||||
myRepositories.put(root, repository);
|
||||
repositories.put(root, repository);
|
||||
}
|
||||
catch (GitRepoStateException e) {
|
||||
LOG.error("Couldn't initialize GitRepository in " + root.getPresentableUrl(), e);
|
||||
@@ -170,6 +169,11 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REPO_LOCK.writeLock().lock();
|
||||
try {
|
||||
myRepositories.clear();
|
||||
myRepositories.putAll(repositories);
|
||||
}
|
||||
finally {
|
||||
REPO_LOCK.writeLock().unlock();
|
||||
|
||||
@@ -333,14 +333,17 @@ public class GroovyMarkerTypes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
public void run(final @NotNull ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
for (PsiMethod method : PsiImplUtil.getMethodOrReflectedMethods(myMethod)) {
|
||||
OverridingMethodsSearch.search(method, true).forEach(
|
||||
new CommonProcessors.CollectProcessor<PsiMethod>() {
|
||||
@Override
|
||||
public boolean process(PsiMethod psiMethod) {
|
||||
updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator());
|
||||
if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator())) {
|
||||
indicator.cancel();
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
@@ -312,9 +313,10 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
}
|
||||
|
||||
return blockPsi instanceof GrParameterList && mySettings.ALIGN_MULTILINE_PARAMETERS ||
|
||||
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
|
||||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
|
||||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION;
|
||||
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
|
||||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
|
||||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION ||
|
||||
blockPsi instanceof GrListOrMap && myGroovySettings.ALIGN_MULTILINE_LIST_OR_MAP;
|
||||
}
|
||||
|
||||
private static boolean isListLikeClause(PsiElement blockPsi) {
|
||||
@@ -323,7 +325,8 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
blockPsi instanceof GrAssignmentExpression ||
|
||||
blockPsi instanceof GrConditionalExpression ||
|
||||
blockPsi instanceof GrExtendsClause ||
|
||||
blockPsi instanceof GrThrowsClause;
|
||||
blockPsi instanceof GrThrowsClause ||
|
||||
blockPsi instanceof GrListOrMap;
|
||||
}
|
||||
|
||||
private static boolean isKeyword(ASTNode node) {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public boolean USE_FLYING_GEESE_BRACES = false;
|
||||
|
||||
public boolean SPACE_IN_NAMED_ARGUMENT = true;
|
||||
public boolean ALIGN_MULTILINE_LIST_OR_MAP = false;
|
||||
|
||||
public GroovyCodeStyleSettings(CodeStyleSettings container) {
|
||||
super("GroovyCodeStyleSettings", container);
|
||||
|
||||
@@ -44,6 +44,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe
|
||||
if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
|
||||
consumer.showAllStandardOptions();
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES", "Use flying geese braces", CodeStyleSettingsCustomizable.WRAPPING_BRACES);
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_MULTILINE_LIST_OR_MAP", "Align when multiple", "List and map literals");
|
||||
return;
|
||||
}
|
||||
if (settingsType == SettingsType.SPACING_SETTINGS) {
|
||||
|
||||
@@ -133,9 +133,14 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes {
|
||||
|
||||
// For arguments
|
||||
if (psiParent instanceof GrArgumentList) {
|
||||
if (child.getElementType() != mLPAREN &&
|
||||
child.getElementType() != mRPAREN) {
|
||||
return Indent.getContinuationIndent();
|
||||
if (child.getElementType() != mLPAREN && child.getElementType() != mRPAREN /*&& child.getElementType() != mCOMMA*/) {
|
||||
return Indent.getContinuationWithoutFirstIndent();
|
||||
}
|
||||
}
|
||||
|
||||
if (psiParent instanceof GrListOrMap) {
|
||||
if (child.getElementType() != mLBRACK && child.getElementType() != mRBRACK /*&& child.getElementType() != mCOMMA*/) {
|
||||
return Indent.getContinuationWithoutFirstIndent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,19 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.editor;
|
||||
|
||||
import com.intellij.codeInsight.editorActions.QuoteHandler;
|
||||
import com.intellij.codeInsight.editorActions.MultiCharQuoteHandler;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class GroovyQuoteHandler implements QuoteHandler {
|
||||
public class GroovyQuoteHandler implements MultiCharQuoteHandler {
|
||||
|
||||
public boolean isClosingQuote(HighlighterIterator iterator, int offset) {
|
||||
final IElementType tokenType = iterator.getTokenType();
|
||||
@@ -42,7 +45,7 @@ public class GroovyQuoteHandler implements QuoteHandler {
|
||||
public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
|
||||
final IElementType tokenType = iterator.getTokenType();
|
||||
|
||||
if (tokenType== mGSTRING_BEGIN) return true;
|
||||
if (tokenType == mGSTRING_BEGIN) return true;
|
||||
if (tokenType == mGSTRING_LITERAL || tokenType == mSTRING_LITERAL) {
|
||||
int start = iterator.getStart();
|
||||
return offset == start;
|
||||
@@ -58,4 +61,16 @@ public class GroovyQuoteHandler implements QuoteHandler {
|
||||
final IElementType tokenType = iterator.getTokenType();
|
||||
return tokenType == mSTRING_LITERAL || tokenType == mGSTRING_LITERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getClosingQuote(HighlighterIterator iterator, int offset) {
|
||||
if (offset >= 3) {
|
||||
Document document = iterator.getDocument();
|
||||
if (document == null) return null;
|
||||
String quote = document.getText(new TextRange(offset - 3, offset));
|
||||
if ("'''".equals(quote)) return quote;
|
||||
if ("\"\"\"".equals(quote)) return quote;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.ElementPresentationUtil;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
@@ -438,29 +437,6 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static GrLightMethodBuilder wrap(PsiMethod method) {
|
||||
GrLightMethodBuilder res = new GrLightMethodBuilder(method.getManager(), method.getName());
|
||||
|
||||
res.setReturnType(method.getReturnType());
|
||||
res.setNavigationElement(method.getNavigationElement());
|
||||
|
||||
res.setContainingClass(method.getContainingClass());
|
||||
|
||||
res.getModifierList().copyModifiers(method);
|
||||
|
||||
for (PsiParameter parameter : method.getParameterList().getParameters()) {
|
||||
GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), parameter.getType(), res);
|
||||
|
||||
if (parameter instanceof GrParameter) {
|
||||
p.setOptional(((GrParameter)parameter).isOptional());
|
||||
}
|
||||
|
||||
res.addParameter(p);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public <T> T getData() {
|
||||
//noinspection unchecked
|
||||
return (T)myData;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.lang.psi.impl.synthetic;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class GrMethodWrapper extends GrLightMethodBuilder {
|
||||
|
||||
private static PsiType TYPE_MARKER = new PsiPrimitiveType("xxx", PsiAnnotation.EMPTY_ARRAY);
|
||||
|
||||
private volatile boolean myNavigationElementInit;
|
||||
|
||||
private final PsiMethod myWrappedMethod;
|
||||
|
||||
private GrMethodWrapper(PsiMethod method) {
|
||||
super(method.getManager(), method.getName());
|
||||
|
||||
myWrappedMethod = method;
|
||||
|
||||
setContainingClass(method.getContainingClass());
|
||||
|
||||
getModifierList().copyModifiers(method);
|
||||
|
||||
for (PsiParameter parameter : method.getParameterList().getParameters()) {
|
||||
GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), parameter.getType(), this);
|
||||
|
||||
if (parameter instanceof GrParameter) {
|
||||
p.setOptional(((GrParameter)parameter).isOptional());
|
||||
}
|
||||
|
||||
addParameter(p);
|
||||
}
|
||||
|
||||
setReturnType(TYPE_MARKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationElement(@NotNull PsiElement navigationElement) {
|
||||
myNavigationElementInit = true;
|
||||
super.setNavigationElement(navigationElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getNavigationElement() {
|
||||
if (!myNavigationElementInit) {
|
||||
setNavigationElement(myWrappedMethod.getNavigationElement()); // getNavigationElement() can get long time if wrapped method is a ClsMethod.
|
||||
}
|
||||
return super.getNavigationElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnType() {
|
||||
PsiType type = super.getReturnType();
|
||||
if (type == TYPE_MARKER) {
|
||||
type = myWrappedMethod.getReturnType();
|
||||
super.setReturnType(type);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
if (myNavigationElementInit) {
|
||||
return super.isValid(); // This will call isValid() on navigationElement
|
||||
}
|
||||
|
||||
return myWrappedMethod.isValid();
|
||||
}
|
||||
|
||||
public static GrMethodWrapper wrap(@NotNull PsiMethod method) {
|
||||
return new GrMethodWrapper(method);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,11 @@ public class StubGenerator implements ClassItemGenerator {
|
||||
return eval.toString() + "f";
|
||||
}
|
||||
else if (eval instanceof Character) {
|
||||
return "'" + ((Character)eval).charValue() + "'";
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append('\'');
|
||||
StringUtil.escapeStringCharacters(1, Character.toString(((Character)eval).charValue()), buffer);
|
||||
buffer.append('\'');
|
||||
return buffer.toString();
|
||||
}
|
||||
if (eval instanceof Number || eval instanceof Boolean) {
|
||||
return eval.toString();
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierFlags;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrMethodWrapper;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
@@ -169,7 +170,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
|
||||
|
||||
private void registerExplicitMethod(String name, String realMethodName) {
|
||||
for (PsiMethod method : mySwingBuilderClass.findMethodsByName(realMethodName, false)) {
|
||||
add(GrLightMethodBuilder.wrap(method));
|
||||
add(GrMethodWrapper.wrap(method));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import com.intellij.debugger.ui.DebuggerPanelsManager
|
||||
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor
|
||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor
|
||||
import com.intellij.execution.process.OSProcessHandler
|
||||
import com.intellij.execution.process.OSProcessManager
|
||||
import com.intellij.execution.process.ProcessAdapter
|
||||
import com.intellij.execution.runners.ProgramRunner
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -47,8 +49,6 @@ import com.intellij.testFramework.builders.JavaModuleFixtureBuilder
|
||||
import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl
|
||||
import com.intellij.util.SystemProperties
|
||||
import com.intellij.util.concurrency.Semaphore
|
||||
import com.intellij.execution.process.OSProcessManager
|
||||
import com.intellij.execution.process.OSProcessHandler
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -241,6 +241,23 @@ new Runnable() {
|
||||
}
|
||||
}
|
||||
|
||||
void testEvalInStaticMethod() {
|
||||
myFixture.addFileToProject('Foo.groovy', '''\
|
||||
static def foo() {
|
||||
int x = 5
|
||||
print x
|
||||
}
|
||||
|
||||
foo()
|
||||
|
||||
''')
|
||||
addBreakpoint 'Foo.groovy', 2
|
||||
runDebugger 'Foo', {
|
||||
waitForBreakpoint()
|
||||
eval 'x', '5'
|
||||
}
|
||||
}
|
||||
|
||||
private def addBreakpoint(String fileName, int line) {
|
||||
VirtualFile file = null
|
||||
edt {
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang;
|
||||
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -24,12 +25,12 @@ import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
public class GroovyEditingTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return TestUtils.getTestDataPath() + "editing/";
|
||||
return TestUtils.testDataPath + "editing/";
|
||||
}
|
||||
|
||||
private void doTest(final char c) throws Throwable {
|
||||
private void doTest(final String c) {
|
||||
myFixture.configureByFile(getTestName(false) + ".groovy");
|
||||
myFixture.type(c);
|
||||
myFixture.type(c as char);
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
|
||||
}
|
||||
|
||||
@@ -43,4 +44,20 @@ public class GroovyEditingTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testPairAngleBracketAfterClassNameOvertype() throws Throwable {doTest('>');}
|
||||
public void testPairAngleBracketAfterClassNameBackspace() throws Throwable {doTest('\b');}
|
||||
public void testNoPairLess() throws Throwable {doTest('<');}
|
||||
|
||||
public void testTripleString() {
|
||||
myFixture.configureByText('_.groovy', '')
|
||||
myFixture.type('\'')
|
||||
myFixture.type('\'')
|
||||
myFixture.type('\'')
|
||||
myFixture.checkResult("'''<caret>'''")
|
||||
}
|
||||
|
||||
public void testTripleGString() {
|
||||
myFixture.configureByText('_.groovy', '')
|
||||
myFixture.type('"')
|
||||
myFixture.type('"')
|
||||
myFixture.type('"')
|
||||
myFixture.checkResult('"""<caret>"""')
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ package org.zmlx.hg4idea;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
|
||||
@@ -67,6 +68,11 @@ public class HgFileRevision implements VcsFileRevision {
|
||||
return branchName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Date getRevisionDate() {
|
||||
return revisionDate;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.idea.maven.indices.MavenIndicesTestFixture;
|
||||
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndicesTestCase {
|
||||
@Override
|
||||
@@ -65,7 +68,15 @@ public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndic
|
||||
" </extensions>" +
|
||||
"</build>");
|
||||
|
||||
assertCompletionVariants(myProjectPom, "maven-compiler-plugin", "maven-war-plugin", "maven-eclipse-plugin", "maven-surefire-plugin");
|
||||
List<String> actual = getCompletionVariants(myProjectPom);
|
||||
|
||||
if (actual.isEmpty()) {
|
||||
MavenProjectIndicesManager instance = MavenProjectIndicesManager.getInstance(myProject);
|
||||
System.out.println("GetArtifacts: " + instance.getArtifactIds("org.apache.maven.plugins"));
|
||||
System.out.println("Indexes: " + instance.getIndices());
|
||||
}
|
||||
|
||||
assertUnorderedElementsAreEqual(actual, "maven-compiler-plugin", "maven-war-plugin", "maven-eclipse-plugin", "maven-surefire-plugin");
|
||||
}
|
||||
|
||||
public void testArtifactWithoutGroupCompletion() throws Exception {
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpellCheckerSeveritiesProvider extends SeveritiesProvider {
|
||||
public static final HighlightSeverity TYPO = new HighlightSeverity("TYPO", 10);
|
||||
public static final HighlightSeverity TYPO = new HighlightSeverity("TYPO", HighlightSeverity.INFORMATION.myVal + 5);
|
||||
|
||||
public List<HighlightInfoType> getSeveritiesHighlightInfoTypes() {
|
||||
final List<HighlightInfoType> result = new ArrayList<HighlightInfoType>();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
@@ -115,6 +116,11 @@ public class SvnFileRevision implements VcsFileRevision {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryLocation getChangedRepositoryPath() {
|
||||
return new SvnRepositoryLocation(myURL);
|
||||
}
|
||||
|
||||
public Date getRevisionDate() {
|
||||
return myDate;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHistorySessionFactory<Boolean, SvnHistoryProvider.MyHistorySession> {
|
||||
private final SvnVcs myVcs;
|
||||
@@ -522,7 +523,7 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
|
||||
private final SVNRevision myPegRevision;
|
||||
protected final String myUrl;
|
||||
private final SvnMergeSourceTracker myTracker;
|
||||
private SVNURL myRepositoryRoot;
|
||||
protected SVNURL myRepositoryRoot;
|
||||
|
||||
public MyLogEntryHandler(SvnVcs vcs, final String url,
|
||||
final SVNRevision pegRevision,
|
||||
@@ -567,9 +568,11 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
|
||||
}
|
||||
|
||||
final int mergeLevel = svnLogEntryIntegerPair.getSecond();
|
||||
final SvnFileRevision revision = createRevision(logEntry, copyPath);
|
||||
final SvnFileRevision revision = createRevision(logEntry, copyPath, entryPath);
|
||||
if (copyPath != null) {
|
||||
myLastPath = copyPath;
|
||||
} else {
|
||||
myLastPath = correctLastPathAccordingToFolderRenames(myLastPath, logEntry);
|
||||
}
|
||||
if (mergeLevel >= 0) {
|
||||
addToListByLevel((SvnFileRevision) myPrevious, revision, mergeLevel);
|
||||
@@ -578,9 +581,26 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
|
||||
myPrevious = revision;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private String correctLastPathAccordingToFolderRenames(String lastPath, SVNLogEntry logEntry) {
|
||||
final Map<String,SVNLogEntryPath> paths = logEntry.getChangedPaths();
|
||||
for (Map.Entry<String, SVNLogEntryPath> entry : paths.entrySet()) {
|
||||
final SVNLogEntryPath value = entry.getValue();
|
||||
final String copyPath = value.getCopyPath();
|
||||
if (copyPath != null) {
|
||||
final String entryPath = value.getPath();
|
||||
if (SVNPathUtil.isAncestor(entryPath, lastPath)) {
|
||||
final String relativePath = SVNPathUtil.getRelativePath(entryPath, lastPath);
|
||||
return SVNPathUtil.append(copyPath, relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastPath;
|
||||
}
|
||||
|
||||
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
|
||||
myTracker.consume(logEntry);
|
||||
}
|
||||
@@ -599,12 +619,13 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
|
||||
}
|
||||
}
|
||||
|
||||
protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) throws SVNException {
|
||||
protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) throws SVNException {
|
||||
Date date = logEntry.getDate();
|
||||
String author = logEntry.getAuthor();
|
||||
String message = logEntry.getMessage();
|
||||
SVNRevision rev = SVNRevision.create(logEntry.getRevision());
|
||||
final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true);
|
||||
// final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true);
|
||||
final SVNURL url = myRepositoryRoot.appendPath(entryPath.getPath(), true);
|
||||
return new SvnFileRevision(myVcs, myPegRevision, rev, url.toString(), author, date, message, copyPath, myCharset);
|
||||
}
|
||||
}
|
||||
@@ -619,10 +640,12 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
|
||||
super(vcs, url, pegRevision, lastPath, result, repoRootURL, null);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) {
|
||||
return new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, myUrl, copyPath, null);
|
||||
}*/
|
||||
@Override
|
||||
protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath)
|
||||
throws SVNException {
|
||||
final SVNURL url = myRepositoryRoot.appendPath(entryPath.getPath(), true);
|
||||
return new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, url.toString(), copyPath, null);
|
||||
}
|
||||
}
|
||||
|
||||
private class MergeSourceColumnInfo extends ColumnInfo<VcsFileRevision, VcsFileRevision> {
|
||||
|
||||