use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class HgHistoryUtil method loadMetadata.
@NotNull
public static List<VcsCommitMetadata> loadMetadata(@NotNull final Project project, @NotNull final VirtualFile root, int limit, @NotNull List<String> parameters) throws VcsException {
final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
if (factory == null) {
return Collections.emptyList();
}
HgVcs hgvcs = HgVcs.getInstance(project);
assert hgvcs != null;
HgVersion version = hgvcs.getVersion();
List<String> templateList = HgBaseLogParser.constructDefaultTemplate(version);
templateList.add("{desc}");
String[] templates = ArrayUtil.toStringArray(templateList);
HgCommandResult result = getLogResult(project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
HgBaseLogParser<VcsCommitMetadata> baseParser = new HgBaseLogParser<VcsCommitMetadata>() {
@Override
protected VcsCommitMetadata 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.createCommitMetadata(factory.createHash(changeset), parentsHash, revisionDate.getTime(), root, subject, author, email, message, author, email, revisionDate.getTime());
}
};
return getCommitRecords(project, result, baseParser);
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class ResourceBundleReference method getVariants.
@Override
@NotNull
public Object[] getVariants() {
final ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(getElement().getProject());
final PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(getElement().getProject());
final Set<String> bundleNames = new HashSet<>();
final List<LookupElement> variants = new SmartList<>();
PropertiesFileProcessor processor = new PropertiesFileProcessor() {
@Override
public boolean process(String baseName, PropertiesFile propertiesFile) {
if (!bundleNames.add(baseName))
return true;
final LookupElementBuilder builder = LookupElementBuilder.create(baseName).withIcon(AllIcons.Nodes.ResourceBundle);
boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile());
variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder);
return true;
}
};
referenceManager.processPropertiesFiles(myElement.getResolveScope(), processor, this);
return variants.toArray(new LookupElement[variants.size()]);
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class MavenArtifactIndex method findArtifacts.
@NotNull
public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId, @Nullable String version) {
Map<String, List<MavenArtifact>> groupMap = myData.get(groupId);
if (groupMap == null)
return Collections.emptyList();
List<MavenArtifact> artifacts = groupMap.get(artifactId);
if (artifacts == null)
return Collections.emptyList();
List<MavenArtifact> res = new SmartList<>();
for (MavenArtifact artifact : artifacts) {
if (Comparing.equal(version, artifact.getVersion())) {
res.add(artifact);
}
}
return res;
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class HtmlFileTreeElement method getChildrenBase.
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
if (isHtml5SectionsMode()) {
// Html5SectionsNodeProvider will return its structure
return Collections.emptyList();
}
final XmlFile xmlFile = getElement();
final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
if (document == null) {
return Collections.emptyList();
}
final List<XmlTag> rootTags = new SmartList<>();
document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);
if (rootTags.isEmpty()) {
return Collections.emptyList();
} else if (rootTags.size() == 1) {
final XmlTag rootTag = rootTags.get(0);
if ("html".equalsIgnoreCase(rootTag.getLocalName())) {
final XmlTag[] subTags = rootTag.getSubTags();
if (subTags.length == 1 && ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) {
return new HtmlTagTreeElement(subTags[0]).getChildrenBase();
}
return new HtmlTagTreeElement(rootTag).getChildrenBase();
}
return Collections.<StructureViewTreeElement>singletonList(new HtmlTagTreeElement(rootTag));
} else {
final Collection<StructureViewTreeElement> result = new ArrayList<>(rootTags.size());
for (XmlTag tag : rootTags) {
result.add(new HtmlTagTreeElement(tag));
}
return result;
}
}
use of com.intellij.util.SmartList in project intellij-community by JetBrains.
the class JavaLineBreakpointType method computeVariants.
@NotNull
@Override
public List<JavaBreakpointVariant> computeVariants(@NotNull Project project, @NotNull XSourcePosition position) {
PsiFile file = PsiManager.getInstance(project).findFile(position.getFile());
if (file == null) {
return Collections.emptyList();
}
SourcePosition pos = SourcePosition.createFromLine(file, position.getLine());
List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(pos, true);
if (lambdas.isEmpty()) {
return Collections.emptyList();
}
PsiElement startMethod = DebuggerUtilsEx.getContainingMethod(pos);
//noinspection SuspiciousMethodCalls
if (lambdas.contains(startMethod) && lambdas.size() == 1) {
return Collections.emptyList();
}
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return Collections.emptyList();
}
List<JavaBreakpointVariant> res = new SmartList<>();
if (!(startMethod instanceof PsiLambdaExpression)) {
// base method
res.add(new LineJavaBreakpointVariant(position, startMethod, -1));
}
int ordinal = 0;
for (PsiLambdaExpression lambda : lambdas) {
//lambdas
PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambda, document, position.getLine());
XSourcePositionImpl elementPosition = XSourcePositionImpl.createByElement(firstElem);
if (elementPosition != null) {
if (lambda == startMethod) {
res.add(0, new LineJavaBreakpointVariant(elementPosition, lambda, ordinal++));
} else {
res.add(new LambdaJavaBreakpointVariant(elementPosition, lambda, ordinal++));
}
}
}
//all
res.add(new JavaBreakpointVariant(position));
return res;
}
Aggregations