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();
}
}
}
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;
}
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;
}
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);
}
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);
}
Aggregations