Search in sources :

Example 91 with THashSet

use of gnu.trove.THashSet in project intellij-community by JetBrains.

the class RunnerAndConfigurationSettingsImpl method checkSettings.

@Override
public void checkSettings(@Nullable Executor executor) throws RuntimeConfigurationException {
    myConfiguration.checkConfiguration();
    if (myConfiguration instanceof RunConfigurationBase) {
        final RunConfigurationBase runConfigurationBase = (RunConfigurationBase) myConfiguration;
        Set<ProgramRunner> runners = new THashSet<>();
        runners.addAll(myRunnerSettings.settings.keySet());
        runners.addAll(myConfigurationPerRunnerSettings.settings.keySet());
        for (ProgramRunner runner : runners) {
            if (executor == null || runner.canRun(executor.getId(), myConfiguration)) {
                runConfigurationBase.checkRunnerSettings(runner, myRunnerSettings.settings.get(runner), myConfigurationPerRunnerSettings.settings.get(runner));
            }
        }
        if (executor != null) {
            runConfigurationBase.checkSettingsBeforeRun();
        }
    }
}
Also used : ProgramRunner(com.intellij.execution.runners.ProgramRunner) THashSet(gnu.trove.THashSet)

Example 92 with THashSet

use of gnu.trove.THashSet in project intellij-community by JetBrains.

the class GenericsHighlightUtil method checkOverrideEquivalentMethods.

static Collection<HighlightInfo> checkOverrideEquivalentMethods(@NotNull PsiClass aClass) {
    List<HighlightInfo> result = new ArrayList<>();
    final Collection<HierarchicalMethodSignature> signaturesWithSupers = aClass.getVisibleSignatures();
    PsiManager manager = aClass.getManager();
    Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods = new THashMap<>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
    final Set<MethodSignature> foundProblems = new THashSet<>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
    for (HierarchicalMethodSignature signature : signaturesWithSupers) {
        HighlightInfo info = checkSameErasureNotSubSignatureInner(signature, manager, aClass, sameErasureMethods);
        if (info != null && foundProblems.add(signature)) {
            result.add(info);
        }
        if (aClass instanceof PsiTypeParameter) {
            info = HighlightMethodUtil.checkMethodIncompatibleReturnType(signature, signature.getSuperSignatures(), true, HighlightNamesUtil.getClassDeclarationTextRange(aClass));
            if (info != null) {
                result.add(info);
            }
        }
    }
    return result.isEmpty() ? null : result;
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) THashSet(gnu.trove.THashSet) THashMap(gnu.trove.THashMap)

Example 93 with THashSet

use of gnu.trove.THashSet in project intellij-community by JetBrains.

the class ImportHelper method collectNamesToImport.

@NotNull
private static // returns list of (name, isImportStatic) pairs
Collection<Pair<String, Boolean>> collectNamesToImport(@NotNull PsiJavaFile file, List<PsiElement> comments) {
    Set<Pair<String, Boolean>> names = new THashSet<>();
    final JspFile jspFile = JspPsiUtil.getJspFile(file);
    collectNamesToImport(names, comments, file, jspFile);
    if (jspFile != null) {
        PsiFile[] files = ArrayUtil.mergeArrays(JspSpiUtil.getIncludingFiles(jspFile), JspSpiUtil.getIncludedFiles(jspFile));
        for (PsiFile includingFile : files) {
            final PsiFile javaRoot = includingFile.getViewProvider().getPsi(JavaLanguage.INSTANCE);
            if (javaRoot instanceof PsiJavaFile && file != javaRoot) {
                collectNamesToImport(names, comments, (PsiJavaFile) javaRoot, jspFile);
            }
        }
    }
    addUnresolvedImportNames(names, file);
    return names;
}
Also used : JspFile(com.intellij.psi.jsp.JspFile) THashSet(gnu.trove.THashSet) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 94 with THashSet

use of gnu.trove.THashSet in project intellij-community by JetBrains.

the class PsiCodeBlockImpl method buildMaps.

// return Pair(classes, locals) or null if there was conflict
@Nullable
private Couple<Set<String>> buildMaps() {
    Set<String> set1 = myClassesSet;
    Set<String> set2 = myVariablesSet;
    boolean wasConflict = myConflict;
    if (set1 == null || set2 == null) {
        final Set<String> localsSet = new THashSet<>();
        final Set<String> classesSet = new THashSet<>();
        final Ref<Boolean> conflict = new Ref<>(Boolean.FALSE);
        PsiScopesUtil.walkChildrenScopes(this, new BaseScopeProcessor() {

            @Override
            public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
                if (element instanceof PsiLocalVariable) {
                    final PsiLocalVariable variable = (PsiLocalVariable) element;
                    final String name = variable.getName();
                    if (!localsSet.add(name)) {
                        conflict.set(Boolean.TRUE);
                        localsSet.clear();
                        classesSet.clear();
                    }
                } else if (element instanceof PsiClass) {
                    final PsiClass psiClass = (PsiClass) element;
                    final String name = psiClass.getName();
                    if (!classesSet.add(name)) {
                        conflict.set(Boolean.TRUE);
                        localsSet.clear();
                        classesSet.clear();
                    }
                }
                return !conflict.get();
            }
        }, ResolveState.initial(), this, this);
        myClassesSet = set1 = classesSet.isEmpty() ? Collections.<String>emptySet() : classesSet;
        myVariablesSet = set2 = localsSet.isEmpty() ? Collections.<String>emptySet() : localsSet;
        myConflict = wasConflict = conflict.get();
    }
    return wasConflict ? null : Couple.of(set1, set2);
}
Also used : BaseScopeProcessor(com.intellij.psi.scope.BaseScopeProcessor) THashSet(gnu.trove.THashSet) Ref(com.intellij.openapi.util.Ref) Nullable(org.jetbrains.annotations.Nullable)

Example 95 with THashSet

use of gnu.trove.THashSet in project intellij-community by JetBrains.

the class PsiReferenceExpressionImpl method processVariants.

@Override
public void processVariants(@NotNull PsiScopeProcessor processor) {
    DelegatingScopeProcessor filterProcessor = new DelegatingScopeProcessor(processor) {

        private PsiElement myResolveContext;

        private final Set<String> myVarNames = new THashSet<>();

        @Override
        public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
            return !shouldProcess(element) || super.execute(element, state);
        }

        private boolean shouldProcess(@NotNull PsiElement element) {
            if (element instanceof PsiVariable)
                return ensureNonShadowedVariable((PsiVariable) element);
            if (element instanceof PsiClass)
                return !seemsScrambled((PsiClass) element);
            if (element instanceof PsiPackage)
                return isQualified();
            if (element instanceof PsiMethod)
                return shouldProcessMethod((PsiMethod) element);
            return false;
        }

        private boolean ensureNonShadowedVariable(@NotNull PsiVariable element) {
            if (element instanceof PsiLocalVariable || element instanceof PsiParameter) {
                myVarNames.add(element.getName());
            }
            if (element instanceof PsiField && myVarNames.contains(element.getName())) {
                return false;
            }
            return true;
        }

        private boolean shouldProcessMethod(@NotNull PsiMethod method) {
            PsiReferenceExpressionImpl ref = PsiReferenceExpressionImpl.this;
            return !method.isConstructor() && hasValidQualifier(method, ref, myResolveContext);
        }

        @Override
        public void handleEvent(@NotNull Event event, Object associated) {
            if (event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT) {
                myResolveContext = (PsiElement) associated;
            }
            super.handleEvent(event, associated);
        }
    };
    PsiScopesUtil.resolveAndWalk(filterProcessor, this, null, true);
}
Also used : THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull) JavaScopeProcessorEvent(com.intellij.psi.scope.JavaScopeProcessorEvent) DelegatingScopeProcessor(com.intellij.psi.scope.DelegatingScopeProcessor)

Aggregations

THashSet (gnu.trove.THashSet)239 NotNull (org.jetbrains.annotations.NotNull)65 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 Project (com.intellij.openapi.project.Project)35 File (java.io.File)35 THashMap (gnu.trove.THashMap)31 Nullable (org.jetbrains.annotations.Nullable)31 Module (com.intellij.openapi.module.Module)29 IOException (java.io.IOException)24 PsiElement (com.intellij.psi.PsiElement)21 PsiFile (com.intellij.psi.PsiFile)18 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)16 java.util (java.util)16 Element (org.jdom.Element)14 Pair (com.intellij.openapi.util.Pair)13 Logger (com.intellij.openapi.diagnostic.Logger)12 ContainerUtil (com.intellij.util.containers.ContainerUtil)12 Document (com.intellij.openapi.editor.Document)11 Library (com.intellij.openapi.roots.libraries.Library)11 StringUtil (com.intellij.openapi.util.text.StringUtil)10