use of com.intellij.util.SmartList in project intellij-plugins by JetBrains.
the class DartSdkLibUtil method disableDartSdk.
public static void disableDartSdk(@NotNull final Collection<Module> modules) {
if (modules.isEmpty())
return;
final List<ModifiableRootModel> models = new SmartList<>();
for (final Module module : modules) {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
for (final OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (isDartSdkOrderEntry(orderEntry)) {
modifiableModel.removeOrderEntry(orderEntry);
}
}
models.add(modifiableModel);
}
DartProjectComponent.commitModifiableModels(modules.iterator().next().getProject(), models);
}
use of com.intellij.util.SmartList in project intellij-plugins by JetBrains.
the class JstdDebugBrowserInfo method build.
@Nullable
public static JstdDebugBrowserInfo build(@NotNull JstdServer server, @NotNull JstdRunSettings runSettings) {
Collection<JstdBrowserInfo> capturedBrowsers = server.getCapturedBrowsers();
List<JstdDebugBrowserInfo> debugBrowserInfos = new SmartList<>();
for (JstdBrowserInfo browserInfo : capturedBrowsers) {
Pair<JavaScriptDebugEngine, WebBrowser> engine = JavaScriptDebugEngine.Companion.findByBrowserIdOrName(browserInfo.getName());
if (engine != null) {
debugBrowserInfos.add(new JstdDebugBrowserInfo(engine, server.getSettings(), browserInfo));
}
}
if (debugBrowserInfos.size() == 1) {
return debugBrowserInfos.get(0);
}
if (debugBrowserInfos.size() > 1) {
WebBrowser preferredBrowser = runSettings.getPreferredDebugBrowser();
for (JstdDebugBrowserInfo info : debugBrowserInfos) {
if (preferredBrowser.equals(info.getBrowser())) {
return info;
}
}
}
return null;
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class XDebuggerUtilImpl method getAllCaretsPositions.
@NotNull
public static Collection<XSourcePosition> getAllCaretsPositions(@NotNull Project project, DataContext context) {
Editor editor = getEditor(project, context);
if (editor == null) {
return Collections.emptyList();
}
VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
List<XSourcePosition> res = new SmartList<>();
for (Caret caret : editor.getCaretModel().getAllCarets()) {
XSourcePositionImpl position = XSourcePositionImpl.createByOffset(file, caret.getOffset());
if (position != null) {
res.add(position);
}
}
return res;
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class BaseInjection method getMatchingRanges.
private static List<TextRange> getMatchingRanges(Matcher matcher, final int length) {
final List<TextRange> list = new SmartList<>();
int start = 0;
while (start < length && matcher.find(start)) {
final int groupCount = matcher.groupCount();
if (groupCount == 0) {
start = matcher.end();
} else {
for (int i = 1; i <= groupCount; i++) {
start = matcher.start(i);
if (start == -1)
continue;
list.add(new TextRange(start, matcher.end(i)));
}
if (start >= matcher.end())
break;
start = matcher.end();
}
}
return list;
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class PathReferenceManagerImpl method doMerge.
private static List<PsiReference> doMerge(final PsiElement element, final List<PsiReference> references) {
List<PsiReference> resolvingRefs = new ArrayList<>();
List<PsiReference> nonResolvingRefs = new ArrayList<>();
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < references.size(); i++) {
PsiReference reference = references.get(i);
assert element.equals(reference.getElement());
if (reference.resolve() != null) {
resolvingRefs.add(reference);
} else {
nonResolvingRefs.add(reference);
}
}
List<PsiReference> result = new ArrayList<>(5);
while (!resolvingRefs.isEmpty()) {
final List<PsiReference> list = new ArrayList<>(5);
final TextRange range = getFirstIntersectingReferences(resolvingRefs, list);
final TextRange textRange = addIntersectingReferences(nonResolvingRefs, list, range);
addToResult(element, result, list, textRange);
}
while (!nonResolvingRefs.isEmpty()) {
final SmartList<PsiReference> list = new SmartList<>();
final TextRange range = getFirstIntersectingReferences(nonResolvingRefs, list);
int endOffset = range.getEndOffset();
for (final PsiReference reference : list) {
endOffset = Math.min(endOffset, reference.getRangeInElement().getEndOffset());
}
addToResult(element, result, list, new TextRange(range.getStartOffset(), endOffset));
}
return result;
}
Aggregations