mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -115,7 +115,7 @@ public class CompileDriver {
|
||||
|
||||
private static final boolean GENERATE_CLASSPATH_INDEX = "true".equals(System.getProperty("generate.classpath.index"));
|
||||
private static final String PROP_PERFORM_INITIAL_REFRESH = "compiler.perform.outputs.refresh.on.start";
|
||||
private boolean myInitialRefreshPerformed = false;
|
||||
private static final Key<Boolean> REFRESH_DONE_KEY = Key.create("_compiler.initial.refresh.done_");
|
||||
|
||||
private static final FileProcessingCompilerAdapterFactory FILE_PROCESSING_COMPILER_ADAPTER_FACTORY = new FileProcessingCompilerAdapterFactory() {
|
||||
public FileProcessingCompilerAdapter create(CompileContext context, FileProcessingCompiler compiler) {
|
||||
@@ -663,8 +663,8 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
boolean needRecalcOutputDirs = false;
|
||||
if (Registry.is(PROP_PERFORM_INITIAL_REFRESH) || !myInitialRefreshPerformed) {
|
||||
myInitialRefreshPerformed = true;
|
||||
if (Registry.is(PROP_PERFORM_INITIAL_REFRESH) || !Boolean.valueOf(REFRESH_DONE_KEY.get(myProject, Boolean.FALSE))) {
|
||||
REFRESH_DONE_KEY.set(myProject, Boolean.TRUE);
|
||||
final long refreshStart = System.currentTimeMillis();
|
||||
|
||||
//need this to make sure the VFS is built
|
||||
|
||||
+82
-45
@@ -37,10 +37,7 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
@@ -389,7 +386,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public void updateOutputRootsLayout(Project project) {
|
||||
final TIntObjectHashMap<Pair<Integer, Integer>> map = buildOutputRootsLayout(project);
|
||||
final TIntObjectHashMap<Pair<Integer, Integer>> map = buildOutputRootsLayout(new ProjectRef(project));
|
||||
synchronized (myProjectOutputRoots) {
|
||||
myProjectOutputRoots.put(getProjectId(project), map);
|
||||
}
|
||||
@@ -467,9 +464,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private TIntObjectHashMap<Pair<Integer, Integer>> buildOutputRootsLayout(Project project) {
|
||||
private TIntObjectHashMap<Pair<Integer, Integer>> buildOutputRootsLayout(ProjectRef projRef) {
|
||||
final TIntObjectHashMap<Pair<Integer, Integer>> map = new TIntObjectHashMap<Pair<Integer, Integer>>();
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
for (Module module : ModuleManager.getInstance(projRef.get()).getModules()) {
|
||||
final CompilerModuleExtension manager = CompilerModuleExtension.getInstance(module);
|
||||
if (manager != null) {
|
||||
final VirtualFile output = manager.getCompilerOutputPath();
|
||||
@@ -905,17 +902,18 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
// made public for tests
|
||||
public void scanSourceContent(final Project project, final Collection<VirtualFile> roots, final int totalRootCount, final boolean isNewRoots) {
|
||||
public void scanSourceContent(final ProjectRef projRef, final Collection<VirtualFile> roots, final int totalRootCount, final boolean isNewRoots) {
|
||||
if (roots.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final int projectId = getProjectId(project);
|
||||
final int projectId = getProjectId(projRef.get());
|
||||
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(projRef.get()).getFileIndex();
|
||||
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
int processed = 0;
|
||||
for (VirtualFile srcRoot : roots) {
|
||||
if (indicator != null) {
|
||||
projRef.get();
|
||||
indicator.setText2(srcRoot.getPresentableUrl());
|
||||
indicator.setFraction(++processed / (double)totalRootCount);
|
||||
}
|
||||
@@ -930,6 +928,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
projRef.get();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -944,6 +945,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final int fileId = getFileId(file);
|
||||
if (fileId > 0 /*file is valid*/) {
|
||||
if (file.isDirectory()) {
|
||||
projRef.get();
|
||||
for (VirtualFile child : file.getChildren()) {
|
||||
processFile(child);
|
||||
}
|
||||
@@ -981,8 +983,8 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private void markOldOutputRoots(final Project project, final TIntObjectHashMap<Pair<Integer, Integer>> currentLayout) {
|
||||
final int projectId = getProjectId(project);
|
||||
private void markOldOutputRoots(final ProjectRef projRef, final TIntObjectHashMap<Pair<Integer, Integer>> currentLayout) {
|
||||
final int projectId = getProjectId(projRef.get());
|
||||
|
||||
final TIntHashSet rootsToMark = new TIntHashSet();
|
||||
synchronized (myProjectOutputRoots) {
|
||||
@@ -1043,16 +1045,14 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
public void run() {
|
||||
new Task.Backgroundable(project, CompilerBundle.message("compiler.initial.scanning.progress.text"), false) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
final ProjectRef projRef = new ProjectRef(project);
|
||||
try {
|
||||
if (project.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
final IntermediateOutputCompiler[] compilers =
|
||||
CompilerManager.getInstance(project).getCompilers(IntermediateOutputCompiler.class);
|
||||
CompilerManager.getInstance(projRef.get()).getCompilers(IntermediateOutputCompiler.class);
|
||||
|
||||
final Set<VirtualFile> intermediateRoots = new HashSet<VirtualFile>();
|
||||
if (compilers.length > 0) {
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
final Module[] modules = ModuleManager.getInstance(projRef.get()).getModules();
|
||||
for (IntermediateOutputCompiler compiler : compilers) {
|
||||
for (Module module : modules) {
|
||||
if (module.isDisposed()) {
|
||||
@@ -1070,9 +1070,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
final List<VirtualFile> projectRoots = Arrays.asList(ProjectRootManager.getInstance(project).getContentSourceRoots());
|
||||
final List<VirtualFile> projectRoots = Arrays.asList(ProjectRootManager.getInstance(projRef.get()).getContentSourceRoots());
|
||||
final int totalRootsCount = projectRoots.size() + intermediateRoots.size();
|
||||
scanSourceContent(project, projectRoots, totalRootsCount, true);
|
||||
scanSourceContent(projRef, projectRoots, totalRootsCount, true);
|
||||
|
||||
if (!intermediateRoots.isEmpty()) {
|
||||
final FileProcessor processor = new FileProcessor() {
|
||||
@@ -1087,13 +1087,16 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
};
|
||||
int processed = projectRoots.size();
|
||||
for (VirtualFile root : intermediateRoots) {
|
||||
projRef.get();
|
||||
indicator.setText2(root.getPresentableUrl());
|
||||
indicator.setFraction(++processed / (double)totalRootsCount);
|
||||
processRecursively(root, false, processor);
|
||||
}
|
||||
}
|
||||
|
||||
markOldOutputRoots(project, buildOutputRootsLayout(project));
|
||||
|
||||
markOldOutputRoots(projRef, buildOutputRootsLayout(projRef));
|
||||
}
|
||||
catch (ProjectRef.ProjectClosedException swallowed) {
|
||||
}
|
||||
finally {
|
||||
synchronized (myInitializationLock) {
|
||||
@@ -1108,7 +1111,6 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private class MyProjectManagerListener extends ProjectManagerAdapter {
|
||||
|
||||
final Map<Project, MessageBusConnection> myConnections = new HashMap<Project, MessageBusConnection>();
|
||||
@@ -1116,39 +1118,54 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
public void projectOpened(final Project project) {
|
||||
final MessageBusConnection conn = project.getMessageBus().connect();
|
||||
myConnections.put(project, conn);
|
||||
final ProjectRef projRef = new ProjectRef(project);
|
||||
conn.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
private VirtualFile[] myRootsBefore;
|
||||
|
||||
public void beforeRootsChange(final ModuleRootEvent event) {
|
||||
myRootsBefore = ProjectRootManager.getInstance(project).getContentSourceRoots();
|
||||
try {
|
||||
myRootsBefore = ProjectRootManager.getInstance(projRef.get()).getContentSourceRoots();
|
||||
}
|
||||
catch (ProjectRef.ProjectClosedException e) {
|
||||
myRootsBefore = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void rootsChanged(final ModuleRootEvent event) {
|
||||
final VirtualFile[] rootsAfter = ProjectRootManager.getInstance(project).getContentSourceRoots();
|
||||
|
||||
{
|
||||
final Set<VirtualFile> newRoots = new HashSet<VirtualFile>();
|
||||
ContainerUtil.addAll(newRoots, rootsAfter);
|
||||
if (myRootsBefore != null) {
|
||||
newRoots.removeAll(Arrays.asList(myRootsBefore));
|
||||
try {
|
||||
try {
|
||||
final VirtualFile[] rootsAfter = ProjectRootManager.getInstance(projRef.get()).getContentSourceRoots();
|
||||
|
||||
{
|
||||
final Set<VirtualFile> newRoots = new HashSet<VirtualFile>();
|
||||
ContainerUtil.addAll(newRoots, rootsAfter);
|
||||
if (myRootsBefore != null) {
|
||||
newRoots.removeAll(Arrays.asList(myRootsBefore));
|
||||
}
|
||||
scanSourceContent(projRef, newRoots, newRoots.size(), true);
|
||||
}
|
||||
|
||||
{
|
||||
final Set<VirtualFile> oldRoots = new HashSet<VirtualFile>();
|
||||
if (myRootsBefore != null) {
|
||||
ContainerUtil.addAll(oldRoots, myRootsBefore);
|
||||
}
|
||||
if (!oldRoots.isEmpty()) {
|
||||
oldRoots.removeAll(Arrays.asList(rootsAfter));
|
||||
}
|
||||
scanSourceContent(projRef, oldRoots, oldRoots.size(), false);
|
||||
}
|
||||
}
|
||||
scanSourceContent(project, newRoots, newRoots.size(), true);
|
||||
finally {
|
||||
myRootsBefore = null;
|
||||
}
|
||||
|
||||
|
||||
markOldOutputRoots(projRef, buildOutputRootsLayout(projRef));
|
||||
}
|
||||
|
||||
{
|
||||
final Set<VirtualFile> oldRoots = new HashSet<VirtualFile>();
|
||||
if (myRootsBefore != null) {
|
||||
ContainerUtil.addAll(oldRoots, myRootsBefore);
|
||||
}
|
||||
if (!oldRoots.isEmpty()) {
|
||||
oldRoots.removeAll(Arrays.asList(rootsAfter));
|
||||
}
|
||||
scanSourceContent(project, oldRoots, oldRoots.size(), false);
|
||||
catch (ProjectRef.ProjectClosedException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
|
||||
myRootsBefore = null;
|
||||
|
||||
markOldOutputRoots(project, buildOutputRootsLayout(project));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1465,4 +1482,24 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ProjectRef extends Ref<Project> {
|
||||
static class ProjectClosedException extends RuntimeException {
|
||||
}
|
||||
|
||||
public ProjectRef() {
|
||||
}
|
||||
|
||||
public ProjectRef(Project project) {
|
||||
super(project);
|
||||
}
|
||||
|
||||
public Project get() {
|
||||
final Project project = super.get();
|
||||
if (project != null && project.isDisposed()) {
|
||||
throw new ProjectClosedException();
|
||||
}
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.ShortcutSet;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.Alarm;
|
||||
@@ -91,7 +92,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}, 100, ModalityState.NON_MODAL);
|
||||
}
|
||||
else {
|
||||
myRefreshNeeded = true;
|
||||
|
||||
@@ -275,7 +275,14 @@ public class ExpectedTypesProvider {
|
||||
}
|
||||
|
||||
@Override public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
|
||||
final PsiType type = getAnnotationMethodType((PsiNameValuePair)initializer.getParent());
|
||||
final PsiElement parent = initializer.getParent();
|
||||
final PsiType type;
|
||||
if (parent instanceof PsiNameValuePair) {
|
||||
type = getAnnotationMethodType((PsiNameValuePair)parent);
|
||||
}
|
||||
else {
|
||||
type = ((PsiAnnotationMethod)parent).getReturnType();
|
||||
}
|
||||
if (type instanceof PsiArrayType) {
|
||||
myResult = new ExpectedTypeInfo[]{createInfoImpl(((PsiArrayType)type).getComponentType(), ExpectedTypeInfo.TYPE_OR_SUBTYPE, type, TailType.UNKNOWN)};
|
||||
}
|
||||
|
||||
+2
@@ -3,6 +3,7 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.VariableLookupItem;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -53,6 +54,7 @@ public class JavaGlobalMemberNameCompletionContributor extends CompletionContrib
|
||||
final PsiReferenceExpression ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiReferenceExpression.class, false);
|
||||
if (ref != null) {
|
||||
ref.bindToElementViaStaticImport(containingClass);
|
||||
PostprocessReformattingAspect.getInstance(ref.getProject()).doPostponedFormatting();
|
||||
}
|
||||
super.handleInsert(context);
|
||||
}
|
||||
|
||||
@@ -1731,21 +1731,20 @@ public class HighlightUtil {
|
||||
rTypeParams = psiClass == null ? PsiTypeParameter.EMPTY_ARRAY : psiClass.getTypeParameters();
|
||||
}
|
||||
|
||||
|
||||
int typeParamColumns = Math.max(lTypeParams.length, rTypeParams.length);
|
||||
@Language("HTML") @NonNls String requredRow = "";
|
||||
@Language("HTML") @NonNls String requiredRow = "";
|
||||
@Language("HTML") @NonNls String foundRow = "";
|
||||
for (int i = 0; i < typeParamColumns; i++) {
|
||||
PsiTypeParameter lTypeParameter = i >= lTypeParams.length ? null : lTypeParams[i];
|
||||
PsiTypeParameter rTypeParameter = i >= rTypeParams.length ? null : rTypeParams[i];
|
||||
PsiType lSubstedType = lTypeParameter == null ? null : lTypeSubstitutor.substitute(lTypeParameter);
|
||||
PsiType rSubstedType = rTypeParameter == null ? null : rTypeSubstitutor.substitute(rTypeParameter);
|
||||
boolean matches = Comparing.equal(lSubstedType, rSubstedType);
|
||||
PsiType lSubstitutedType = lTypeParameter == null ? null : lTypeSubstitutor.substitute(lTypeParameter);
|
||||
PsiType rSubstitutedType = rTypeParameter == null ? null : rTypeSubstitutor.substitute(rTypeParameter);
|
||||
boolean matches = Comparing.equal(lSubstitutedType, rSubstitutedType);
|
||||
@NonNls String openBrace = i == 0 ? "<" : "";
|
||||
@NonNls String closeBrace = i == typeParamColumns - 1 ? ">" : ",";
|
||||
requredRow += "<td>" + (lTypeParams.length == 0 ? "" : openBrace) + redIfNotMatch(lSubstedType, matches) +
|
||||
(i < lTypeParams.length ? closeBrace : "") + "</td>";
|
||||
foundRow += "<td>" + (rTypeParams.length == 0 ? "" : openBrace) + redIfNotMatch(rSubstedType, matches) +
|
||||
requiredRow += "<td>" + (lTypeParams.length == 0 ? "" : openBrace) + redIfNotMatch(lSubstitutedType, matches) +
|
||||
(i < lTypeParams.length ? closeBrace : "") + "</td>";
|
||||
foundRow += "<td>" + (rTypeParams.length == 0 ? "" : openBrace) + redIfNotMatch(rSubstitutedType, matches) +
|
||||
(i < rTypeParams.length ? closeBrace : "") + "</td>";
|
||||
}
|
||||
PsiType lRawType = lType1 instanceof PsiClassType ? ((PsiClassType)lType1).rawType() : lType1;
|
||||
@@ -1753,7 +1752,7 @@ public class HighlightUtil {
|
||||
boolean assignable = lRawType == null || rRawType == null || TypeConversionUtil.isAssignable(lRawType, rRawType);
|
||||
|
||||
String toolTip = JavaErrorMessages.message("incompatible.types.html.tooltip",
|
||||
redIfNotMatch(lRawType, assignable), requredRow,
|
||||
redIfNotMatch(lRawType, assignable), requiredRow,
|
||||
redIfNotMatch(rRawType, assignable), foundRow);
|
||||
|
||||
String description = JavaErrorMessages.message("incompatible.types", formatType(lType1), formatType(rType1));
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
@@ -466,10 +467,13 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
|
||||
return InheritanceImplUtil.isInheritor(this, baseClass, checkDeep);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiClass getSourceMirrorClass() {
|
||||
PsiElement parent = getParent();
|
||||
final String name = getName();
|
||||
if (parent instanceof PsiFile) {
|
||||
if (!(parent instanceof PsiClassOwner)) return null;
|
||||
|
||||
PsiClassOwner fileNavigationElement = (PsiClassOwner)parent.getNavigationElement();
|
||||
for (PsiClass aClass : fileNavigationElement.getClasses()) {
|
||||
if (name.equals(aClass.getName())) return aClass;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,5 +28,8 @@ public abstract class CompletionConfidence {
|
||||
@Nullable
|
||||
public abstract Boolean shouldFocusLookup(@NotNull CompletionParameters parameters);
|
||||
|
||||
|
||||
@Nullable
|
||||
public Boolean shouldSkipAutopopup(@Nullable PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -193,6 +193,23 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
};
|
||||
if (autopopup) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(initCmd);
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, offset);
|
||||
if (elementAt == null) {
|
||||
elementAt = psiFile.findElementAt(offset);
|
||||
if (elementAt == null && offset > 0) {
|
||||
elementAt = psiFile.findElementAt(offset - 1);
|
||||
}
|
||||
}
|
||||
|
||||
Language language = elementAt != null ? PsiUtilBase.findLanguageFromElement(elementAt):psiFile.getLanguage();
|
||||
|
||||
for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
|
||||
final Boolean result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset); // TODO: Peter Lazy API
|
||||
if (result == Boolean.TRUE) return;
|
||||
}
|
||||
} else {
|
||||
CommandProcessor.getInstance().executeCommand(project, initCmd, null, null);
|
||||
}
|
||||
|
||||
+1
@@ -622,6 +622,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
final String newPrefix = text.subSequence(pair.first, caretOffset).toString();
|
||||
if (pair.second.accepts(newPrefix)) {
|
||||
scheduleRestart();
|
||||
myRestartingPrefixConditions.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-30
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation;
|
||||
import com.intellij.navigation.ChooseByNameContributor;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileNameMatcher;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -32,7 +31,6 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -88,12 +86,7 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
final PsiElement e = parameters.getPosition();
|
||||
final Project project = e.getProject();
|
||||
|
||||
final PsiReference psiReference = ApplicationManager.getApplication().runReadAction(new Computable<PsiReference>() {
|
||||
public PsiReference compute() {
|
||||
//noinspection ConstantConditions
|
||||
return parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
|
||||
}
|
||||
});
|
||||
final PsiReference psiReference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
|
||||
|
||||
final Pair<FileReference, Boolean> fileReferencePair = getReference(psiReference);
|
||||
if (fileReferencePair != null) {
|
||||
@@ -102,11 +95,17 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
|
||||
final FileReferenceSet set = first.getFileReferenceSet();
|
||||
String prefix = set.getPathString().substring(0, parameters.getOffset() - set.getElement().getTextRange().getStartOffset() - set.getStartInElement());
|
||||
final String textBeforePosition = e.getContainingFile().getText().substring(0, parameters.getOffset());
|
||||
if (!textBeforePosition.endsWith(prefix)) {
|
||||
final int len = textBeforePosition.length();
|
||||
final String fragment = len > 100 ? textBeforePosition.substring(len - 100) : textBeforePosition;
|
||||
throw new AssertionError("prefix should be some actual file string just before caret: " + prefix + "\n text=" + fragment + ";\npathString=" + set.getPathString() + ";\nelementText=" + e.getParent().getText());
|
||||
}
|
||||
|
||||
final List<String>[] pathPrefixParts = new List[] {null};
|
||||
List<String> pathPrefixParts = null;
|
||||
int lastSlashIndex;
|
||||
if ((lastSlashIndex = prefix.lastIndexOf('/')) != -1) {
|
||||
pathPrefixParts[0] = StringUtil.split(prefix.substring(0, lastSlashIndex), "/");
|
||||
pathPrefixParts = StringUtil.split(prefix.substring(0, lastSlashIndex), "/");
|
||||
prefix = prefix.substring(lastSlashIndex + 1);
|
||||
}
|
||||
|
||||
@@ -133,28 +132,20 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
for (final String name : resultNames) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
final PsiFile[] files = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
|
||||
public PsiFile[] compute() {
|
||||
return FilenameIndex.getFilesByName(project, name, scope);
|
||||
}
|
||||
});
|
||||
final PsiFile[] files = FilenameIndex.getFilesByName(project, name, scope);
|
||||
|
||||
if (files.length > 0) {
|
||||
for (final PsiFile file : files) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null && virtualFile.isValid() && virtualFile != contextFile) {
|
||||
if (contextHelper.isMine(project, virtualFile)) {
|
||||
if (pathPrefixParts[0] == null || fileMatchesPathPrefix(contextHelper.getPsiFileSystemItem(project, virtualFile), pathPrefixParts[0])) {
|
||||
__result.addElement(new FilePathLookupItem(file, contextHelper));
|
||||
}
|
||||
}
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null && virtualFile.isValid() && virtualFile != contextFile) {
|
||||
if (contextHelper.isMine(project, virtualFile)) {
|
||||
if (pathPrefixParts == null || fileMatchesPathPrefix(contextHelper.getPsiFileSystemItem(project, virtualFile), pathPrefixParts)) {
|
||||
__result.addElement(new FilePathLookupItem(file, contextHelper));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,11 +211,7 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
final ChooseByNameContributor[] nameContributors = ChooseByNameContributor.FILE_EP_NAME.getExtensions();
|
||||
for (final ChooseByNameContributor contributor : nameContributors) {
|
||||
try {
|
||||
names.addAll(ApplicationManager.getApplication().runReadAction(new Computable<Collection<? extends String>>() {
|
||||
public Collection<? extends String> compute() {
|
||||
return Arrays.asList(contributor.getNames(project, false));
|
||||
}
|
||||
}));
|
||||
names.addAll(Arrays.asList(contributor.getNames(project, false)));
|
||||
}
|
||||
catch (ProcessCanceledException ex) {
|
||||
// index corruption detected, ignore
|
||||
|
||||
+8
-3
@@ -93,9 +93,14 @@ public class ShowJavaDocInfoAction extends BaseCodeInsightAction implements Hint
|
||||
}
|
||||
|
||||
if (element == null && file != null) {
|
||||
final PsiReference ref = file.findReferenceAt(editor.getCaretModel().getOffset());
|
||||
if (ref instanceof PsiPolyVariantReference) {
|
||||
element = ref.getElement();
|
||||
try {
|
||||
final PsiReference ref = file.findReferenceAt(editor.getCaretModel().getOffset());
|
||||
if (ref instanceof PsiPolyVariantReference) {
|
||||
element = ref.getElement();
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
element = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
|
||||
for(EnterHandlerDelegate delegate: Extensions.getExtensions(EnterHandlerDelegate.EP_NAME)) {
|
||||
EnterHandlerDelegate.Result result = delegate.preprocessEnter(file, editor, caretOffsetRef, caretAdvanceRef, dataContext, myOriginalHandler);
|
||||
if (caretOffsetRef.get() > document.getTextLength()) {
|
||||
throw new AssertionError("Wrong caret offset change by " + delegate);
|
||||
}
|
||||
|
||||
if (result == EnterHandlerDelegate.Result.Stop) return;
|
||||
if (result != EnterHandlerDelegate.Result.Continue) {
|
||||
text = document.getCharsSequence();
|
||||
|
||||
+20
-13
@@ -21,7 +21,9 @@ import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -85,20 +87,25 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
public boolean processFilesWithWord(@NotNull final Processor<PsiFile> psiFileProcessor, @NotNull final String word, final short occurrenceMask, @NotNull final GlobalSearchScope scope, final boolean caseSensitively) {
|
||||
final Set<VirtualFile> vFiles = new THashSet<VirtualFile>();
|
||||
final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myProject);
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
FileBasedIndex.getInstance().processValues(IdIndex.NAME, new IdIndexEntry(word, caseSensitively), null, new FileBasedIndex.ValueProcessor<Integer>() {
|
||||
public boolean process(final VirtualFile file, final Integer value) {
|
||||
ProgressManager.checkCanceled();
|
||||
final int mask = value.intValue();
|
||||
if ((mask & occurrenceMask) != 0) {
|
||||
vFiles.add(file);
|
||||
try {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
FileBasedIndex.getInstance().processValues(IdIndex.NAME, new IdIndexEntry(word, caseSensitively), null, new FileBasedIndex.ValueProcessor<Integer>() {
|
||||
public boolean process(final VirtualFile file, final Integer value) {
|
||||
ProgressManager.checkCanceled();
|
||||
final int mask = value.intValue();
|
||||
if ((mask & occurrenceMask) != 0) {
|
||||
vFiles.add(file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, projectScope);
|
||||
}
|
||||
});
|
||||
}, projectScope);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
|
||||
if (vFiles.isEmpty()) return true;
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public class ASTDiffBuilder implements DiffTreeChangeBuilder<ASTNode, ASTNode> {
|
||||
}
|
||||
else {
|
||||
final ASTNode parent = oldNode.getTreeParent();
|
||||
assert parent != null : "old:" + oldNode + " new:" + newNode;
|
||||
|
||||
TreeUtil.ensureParsed(oldNode);
|
||||
|
||||
|
||||
@@ -482,11 +482,12 @@ public class JDOMUtil {
|
||||
* Returns null if no escapement necessary.
|
||||
*/
|
||||
@Nullable
|
||||
private static String escapeChar(char c, boolean escapeLineEnds) {
|
||||
private static String escapeChar(char c, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
switch (c) {
|
||||
case '\n': return escapeLineEnds ? " " : null;
|
||||
case '\r': return escapeLineEnds ? " " : null;
|
||||
case '\t': return escapeLineEnds ? "	" : null;
|
||||
case ' ' : return escapeSpaces ? "" : null;
|
||||
case '<': return "<";
|
||||
case '>': return ">";
|
||||
case '\"': return """;
|
||||
@@ -497,15 +498,15 @@ public class JDOMUtil {
|
||||
|
||||
@NotNull
|
||||
public static String escapeText(String text) {
|
||||
return escapeText(text, false);
|
||||
return escapeText(text, false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String escapeText(String text, boolean escapeLineEnds) {
|
||||
public static String escapeText(String text, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
StringBuffer buffer = null;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
final char ch = text.charAt(i);
|
||||
final String quotation = escapeChar(ch, escapeLineEnds);
|
||||
final String quotation = escapeChar(ch, escapeSpaces, escapeLineEnds);
|
||||
|
||||
if (buffer == null) {
|
||||
if (quotation != null) {
|
||||
@@ -548,11 +549,11 @@ public class JDOMUtil {
|
||||
|
||||
public static class MyXMLOutputter extends XMLOutputter {
|
||||
public String escapeAttributeEntities(String str) {
|
||||
return escapeText(str, true);
|
||||
return escapeText(str, false, true);
|
||||
}
|
||||
|
||||
public String escapeElementEntities(String str) {
|
||||
return escapeText(str, false);
|
||||
return escapeText(str, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 Bas Leijdekkers
|
||||
* Copyright 2006-2010 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,14 +30,11 @@ public class SynchronizationUtil {
|
||||
if (context instanceof PsiSynchronizedStatement) {
|
||||
return true;
|
||||
}
|
||||
if (context != null) {
|
||||
final PsiModifierListOwner modifierListOwner =
|
||||
(PsiModifierListOwner)context;
|
||||
if (modifierListOwner.hasModifierProperty(
|
||||
PsiModifier.SYNCHRONIZED)) {
|
||||
return true;
|
||||
}
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
final PsiModifierListOwner modifierListOwner =
|
||||
(PsiModifierListOwner)context;
|
||||
return modifierListOwner.hasModifierProperty(PsiModifier.SYNCHRONIZED);
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -20,6 +20,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.SynchronizationUtil;
|
||||
import com.siyeh.ig.psiutils.VariableAccessUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -57,7 +58,7 @@ public class NonAtomicOperationOnVolatileFieldInspection
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = expression.getLExpression();
|
||||
final PsiField volatileField = findVolatileField(lhs);
|
||||
final PsiField volatileField = findNonSynchronizedVolatileField(lhs);
|
||||
if (volatileField == null) {
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +89,8 @@ public class NonAtomicOperationOnVolatileFieldInspection
|
||||
if (operand == null) {
|
||||
return;
|
||||
}
|
||||
final PsiField volatileField = findVolatileField(operand);
|
||||
final PsiField volatileField =
|
||||
findNonSynchronizedVolatileField(operand);
|
||||
if (volatileField == null) {
|
||||
return;
|
||||
}
|
||||
@@ -99,7 +101,8 @@ public class NonAtomicOperationOnVolatileFieldInspection
|
||||
public void visitPostfixExpression(PsiPostfixExpression expression) {
|
||||
super.visitPostfixExpression(expression);
|
||||
final PsiExpression operand = expression.getOperand();
|
||||
final PsiField volatileField = findVolatileField(operand);
|
||||
final PsiField volatileField =
|
||||
findNonSynchronizedVolatileField(operand);
|
||||
if (volatileField == null) {
|
||||
return;
|
||||
}
|
||||
@@ -107,12 +110,16 @@ public class NonAtomicOperationOnVolatileFieldInspection
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiField findVolatileField(PsiExpression expression) {
|
||||
private static PsiField findNonSynchronizedVolatileField(
|
||||
PsiExpression expression) {
|
||||
if (!(expression instanceof PsiReferenceExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceExpression reference =
|
||||
(PsiReferenceExpression)expression;
|
||||
if (SynchronizationUtil.isInSynchronizedContext(reference)) {
|
||||
return null;
|
||||
}
|
||||
final PsiElement referent = reference.resolve();
|
||||
if (!(referent instanceof PsiField)) {
|
||||
return null;
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ This inspection reports any non-atomic operations on volatile fields. Non-atomic
|
||||
operations on volatile fields are operations where the volatile field is read and
|
||||
the value is used to update the volatile field. It is possible for the value of the
|
||||
field to change between the read and write, making the operation possibly invalid.
|
||||
In such cases it is better to use one of the <b><font
|
||||
color="#000080">Atomic*</font></b> or
|
||||
In such cases it is better to surround the operation with a synchronized block or
|
||||
make use of one of the <b><font color="#000080">Atomic*</font></b> or
|
||||
<b><font color="#000080">Atomic*FieldUpdater</font></b> classes
|
||||
from the <b><font color="#000080">java.util.concurrent.atomic</font></b> package.
|
||||
</font></td> </tr> <tr> <td height="20"> <font face="verdana" size="-2">New in 10, Powered by InspectionGadgets</font> </td> </tr> </table> </body>
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public final class XmlLanguageInjector implements MultiHostInjector {
|
||||
|
||||
public XmlLanguageInjector(Configuration configuration) {
|
||||
myConfiguration = configuration;
|
||||
mySupport = InjectorUtils.findInjectionSupport(LanguageInjectionSupport.JAVA_SUPPORT_ID);
|
||||
mySupport = InjectorUtils.findInjectionSupport(LanguageInjectionSupport.XML_SUPPORT_ID);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -426,7 +426,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
});
|
||||
}
|
||||
else {
|
||||
myStartupManager.registerPostStartupActivity(new Runnable() {
|
||||
myStartupManager.runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GithubUtil {
|
||||
public static HttpMethod doREST(final String login, final String password, final String request, final boolean post) throws Exception {
|
||||
final HttpClient client = getHttpClient(login, password);
|
||||
client.getParams().setContentCharset("UTF-8");
|
||||
final String uri = getUrl() + JDOMUtil.escapeText(request).replaceAll(" ", "%20");
|
||||
final String uri = JDOMUtil.escapeText(getUrl() + request, true, true);
|
||||
final HttpMethod method = post ? new PostMethod(uri) : new GetMethod(uri);
|
||||
client.executeMethod(method);
|
||||
return method;
|
||||
|
||||
@@ -13,7 +13,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GitHubSettingsConfigurable implements SearchableConfigurable {
|
||||
public static final Icon ICON = IconLoader.getIcon("/icons/github.png");
|
||||
private GithubLoginPanel mySettingsPane;
|
||||
private GithubSettingsPanel mySettingsPane;
|
||||
private final GithubSettings mySettings;
|
||||
|
||||
public GitHubSettingsConfigurable() {
|
||||
@@ -34,7 +34,7 @@ public class GitHubSettingsConfigurable implements SearchableConfigurable {
|
||||
|
||||
public JComponent createComponent() {
|
||||
if (mySettingsPane == null) {
|
||||
mySettingsPane = new GithubLoginPanel();
|
||||
mySettingsPane = new GithubSettingsPanel();
|
||||
}
|
||||
reset();
|
||||
return mySettingsPane.getPanel();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Repository:"/>
|
||||
<text value="&Repository:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8545c" class="javax.swing.JLabel">
|
||||
@@ -26,7 +26,7 @@
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Folder:"/>
|
||||
<text value="&Parent Directory"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7fdf3" class="javax.swing.JLabel">
|
||||
@@ -34,7 +34,7 @@
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Project name:"/>
|
||||
<text value="Directory &Name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8e19a" class="javax.swing.JTextPane" binding="myDetailsTextField" default-binding="true">
|
||||
|
||||
@@ -17,7 +17,7 @@ public class GithubLoginDialog extends DialogWrapper {
|
||||
// TODO: login to github must be merged with tasks server settings
|
||||
public GithubLoginDialog(final Project project) {
|
||||
super(project, true);
|
||||
myGithubLoginPanel = new GithubLoginPanel();
|
||||
myGithubLoginPanel = new GithubLoginPanel(this);
|
||||
final GithubSettings settings = GithubSettings.getInstance();
|
||||
myGithubLoginPanel.setLogin(settings.getLogin());
|
||||
myGithubLoginPanel.setPassword(settings.getPassword());
|
||||
@@ -58,4 +58,8 @@ public class GithubLoginDialog extends DialogWrapper {
|
||||
setErrorText("Cannot login with given credentials");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearErrors() {
|
||||
setErrorText(null);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubLoginPanel">
|
||||
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
<xy x="20" y="20" width="500" height="106"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e76ec" class="javax.swing.JTextField" binding="myLoginTextField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -38,7 +38,8 @@
|
||||
<component id="28ddd" class="javax.swing.JTextPane" binding="mySignupTextField">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="10"/>
|
||||
<minimum-size width="-1" height="20"/>
|
||||
<preferred-size width="150" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -53,7 +54,7 @@
|
||||
</component>
|
||||
<component id="9edbd" class="javax.swing.JPasswordField" binding="myPasswordField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -62,17 +63,12 @@
|
||||
<caretAspectRatio class="java.lang.Float" value="0.04"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<component id="8a6dd" class="javax.swing.JButton" binding="myTestButton" default-binding="true">
|
||||
<vspacer id="f3776">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Test"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="6ace">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="27"/>
|
||||
<preferred-size width="-1" height="27"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.github.ui;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.HyperlinkAdapter;
|
||||
import org.jetbrains.plugins.github.GithubUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
@@ -22,9 +35,8 @@ public class GithubLoginPanel {
|
||||
private JPasswordField myPasswordField;
|
||||
private JTextPane mySignupTextField;
|
||||
private JPanel myPane;
|
||||
private JButton myTestButton;
|
||||
|
||||
public GithubLoginPanel() {
|
||||
public GithubLoginPanel(final GithubLoginDialog dialog) {
|
||||
mySignupTextField.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(final HyperlinkEvent e) {
|
||||
@@ -35,11 +47,16 @@ public class GithubLoginPanel {
|
||||
"<html>Do not have an account? <a href=\"" + SIGNUP_FOR_FREE_ACOUNT + "\">" + "Signup for free" + "</a></html>");
|
||||
mySignupTextField.setBackground(myPane.getBackground());
|
||||
mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
myTestButton.addActionListener(new ActionListener() {
|
||||
myLoginTextField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final boolean result = GithubUtil.testConnection(getLogin(), getPassword());
|
||||
Messages.showInfoMessage(result ? "Connection successful" : "Cannot login using given credentials", result ? "Success" : "Fail");
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
dialog.clearErrors();
|
||||
}
|
||||
});
|
||||
myPasswordField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
dialog.clearErrors();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubSettingsPanel">
|
||||
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e76ec" class="javax.swing.JTextField" binding="myLoginTextField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<caretAspectRatio class="java.lang.Float" value="0.04"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<component id="c0234" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Login"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d7c6c" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Password"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="28ddd" class="javax.swing.JTextPane" binding="mySignupTextField">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="10"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<contentType value="text/html"/>
|
||||
<editable value="false"/>
|
||||
<enabled value="true"/>
|
||||
</properties>
|
||||
<clientProperties>
|
||||
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="true"/>
|
||||
<caretAspectRatio class="java.lang.Float" value="0.04"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<component id="9edbd" class="javax.swing.JPasswordField" binding="myPasswordField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<caretAspectRatio class="java.lang.Float" value="0.04"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<component id="8a6dd" class="javax.swing.JButton" binding="myTestButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Test"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="6ace">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.github.ui;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.HyperlinkAdapter;
|
||||
import org.jetbrains.plugins.github.GithubUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
* @date 10/20/10
|
||||
*/
|
||||
public class GithubSettingsPanel {
|
||||
private static final String SIGNUP_FOR_FREE_ACOUNT = "https://github.com/signup/free";
|
||||
|
||||
private JTextField myLoginTextField;
|
||||
private JPasswordField myPasswordField;
|
||||
private JTextPane mySignupTextField;
|
||||
private JPanel myPane;
|
||||
private JButton myTestButton;
|
||||
|
||||
public GithubSettingsPanel() {
|
||||
mySignupTextField.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(final HyperlinkEvent e) {
|
||||
BrowserUtil.launchBrowser(e.getURL().toExternalForm());
|
||||
}
|
||||
});
|
||||
mySignupTextField.setText(
|
||||
"<html>Do not have an account? <a href=\"" + SIGNUP_FOR_FREE_ACOUNT + "\">" + "Signup for free" + "</a></html>");
|
||||
mySignupTextField.setBackground(myPane.getBackground());
|
||||
mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
myTestButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final boolean result = GithubUtil.testConnection(getLogin(), getPassword());
|
||||
Messages.showInfoMessage(result ? "Connection successful" : "Cannot login using given credentials", result ? "Success" : "Fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JComponent getPanel() {
|
||||
return myPane;
|
||||
}
|
||||
|
||||
public void setLogin(final String login) {
|
||||
myLoginTextField.setText(login);
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
myPasswordField.setText(password);
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return myLoginTextField.getText();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return String.valueOf(myPasswordField.getPassword());
|
||||
}
|
||||
|
||||
public JComponent getPreferrableFocusComponent() {
|
||||
return myLoginTextField;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
|
||||
CompilerManagerImpl.testSetup();
|
||||
|
||||
List<VirtualFile> roots = Arrays.asList(ProjectRootManager.getInstance(myProject).getContentRoots());
|
||||
TranslatingCompilerFilesMonitor.getInstance().scanSourceContent(myProject, roots, roots.size(), true);
|
||||
TranslatingCompilerFilesMonitor.getInstance().scanSourceContent(new TranslatingCompilerFilesMonitor.ProjectRef(myProject), roots, roots.size(), true);
|
||||
|
||||
final CompileScope scope = new ModuleCompileScope(myProject, modules.toArray(new Module[modules.size()]), false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user