use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class MvcModuleStructureUtil method removeAuxiliaryModule.
public static void removeAuxiliaryModule(Module toRemove) {
List<ModifiableRootModel> usingModels = new SmartList<>();
Project project = toRemove.getProject();
ModuleManager moduleManager = ModuleManager.getInstance(project);
for (Module module : moduleManager.getModules()) {
if (module == toRemove) {
continue;
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
for (OrderEntry entry : moduleRootManager.getOrderEntries()) {
if (entry instanceof ModuleOrderEntry && toRemove == ((ModuleOrderEntry) entry).getModule()) {
usingModels.add(moduleRootManager.getModifiableModel());
break;
}
}
}
final ModifiableModuleModel moduleModel = moduleManager.getModifiableModel();
ModuleDeleteProvider.removeModule(toRemove, null, usingModels, moduleModel);
ModifiableModelCommitter.multiCommit(usingModels, moduleModel);
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class BaseSplitter method excludeByPattern.
@NotNull
protected static List<TextRange> excludeByPattern(String text, TextRange range, @NotNull Pattern toExclude, int groupToInclude) {
List<TextRange> toCheck = new SmartList<>();
int from = range.getStartOffset();
int till;
boolean addLast = true;
Matcher matcher = toExclude.matcher(StringUtil.newBombedCharSequence(range.substring(text), 500));
try {
while (matcher.find()) {
checkCancelled();
TextRange found = matcherRange(range, matcher);
till = found.getStartOffset();
if (range.getEndOffset() - found.getEndOffset() < MIN_RANGE_LENGTH) {
addLast = false;
}
if (!badSize(from, till)) {
toCheck.add(new TextRange(from, till));
}
if (groupToInclude > 0) {
TextRange contentFound = matcherRange(range, matcher, groupToInclude);
if (badSize(contentFound.getEndOffset(), contentFound.getStartOffset())) {
toCheck.add(TextRange.create(contentFound));
}
}
from = found.getEndOffset();
}
till = range.getEndOffset();
if (badSize(from, till)) {
return toCheck;
}
if (addLast) {
toCheck.add(new TextRange(from, till));
}
return toCheck;
} catch (ProcessCanceledException e) {
return Collections.singletonList(range);
}
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class OverriddenDefineRenderer method getClickAction.
@Override
@Nullable
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final PsiElement element = myDefine.getPsiElement();
if (element == null || !element.isValid())
return;
final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<>();
final XmlFile localFile = (XmlFile) element.getContainingFile();
RelaxIncludeIndex.processBackwardDependencies(localFile, collector);
final Collection<XmlFile> files = collector.getCollection();
final List<Define> result = new SmartList<>();
final OverriddenDefineSearcher searcher = new OverriddenDefineSearcher(myDefine, localFile, result);
for (XmlFile file : files) {
final Grammar grammar = GrammarFactory.getGrammar(file);
if (grammar == null)
continue;
grammar.acceptChildren(searcher);
}
if (result.size() > 0) {
OverridingDefineRenderer.doClickAction(e, result, "Go to overriding define(s)");
}
}
};
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class HgBaseLogParser method parseParentRevisions.
@NotNull
protected static SmartList<HgRevisionNumber> parseParentRevisions(@NotNull String parentsString, @NotNull String currentRevisionString) {
SmartList<HgRevisionNumber> parents = new SmartList<>();
if (StringUtil.isEmptyOrSpaces(parentsString)) {
// parents shouldn't be empty only if not supported
Long revision = Long.valueOf(currentRevisionString);
HgRevisionNumber parentRevision = HgRevisionNumber.getLocalInstance(String.valueOf(revision - 1));
parents.add(parentRevision);
return parents;
}
//hg returns parents in the format 'rev:node rev:node ' (note the trailing space)
List<String> parentStrings = StringUtil.split(parentsString.trim(), " ");
for (String parentString : parentStrings) {
List<String> parentParts = StringUtil.split(parentString, ":");
// its second parent has revision number -1
if (Integer.valueOf(parentParts.get(0)) >= 0) {
parents.add(HgRevisionNumber.getInstance(parentParts.get(0), parentParts.get(1)));
}
}
return parents;
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class HgHistoryUtil method readMiniDetails.
@NotNull
public static List<? extends VcsShortCommitDetails> readMiniDetails(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull List<String> hashes) throws VcsException {
final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
if (factory == null) {
return Collections.emptyList();
}
HgVcs hgvcs = HgVcs.getInstance(project);
assert hgvcs != null;
final HgVersion version = hgvcs.getVersion();
List<String> templateList = HgBaseLogParser.constructDefaultTemplate(version);
templateList.add("{desc}");
final String[] templates = ArrayUtil.toStringArray(templateList);
return VcsFileUtil.foreachChunk(prepareHashes(hashes), 2, strings -> {
HgCommandResult logResult = getLogResult(project, root, version, -1, strings, HgChangesetUtil.makeTemplate(templates));
return getCommitRecords(project, logResult, new HgBaseLogParser<VcsShortCommitDetails>() {
@Override
protected VcsShortCommitDetails convertDetails(@NotNull String rev, @NotNull String changeset, @NotNull SmartList<HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) {
String message = parseAdditionalStringAttribute(attributes, MESSAGE_INDEX);
String subject = extractSubject(message);
List<Hash> parentsHash = new SmartList<>();
for (HgRevisionNumber parent : parents) {
parentsHash.add(factory.createHash(parent.getChangeset()));
}
return factory.createShortDetails(factory.createHash(changeset), parentsHash, revisionDate.getTime(), root, subject, author, email, author, email, revisionDate.getTime());
}
});
});
}
Aggregations