use of gnu.trove.THashSet in project intellij-plugins by JetBrains.
the class DartControlFlowUtil method getSimpleDeclarations.
public static Set<DartComponentName> getSimpleDeclarations(PsiElement[] children, @Nullable PsiElement lastParent, boolean stopAtLastParent) {
final Set<DartComponentName> result = new THashSet<>();
boolean addComponentsFlag = true;
for (PsiElement child : children) {
if (child == lastParent && stopAtLastParent) {
addComponentsFlag = false;
}
if (addComponentsFlag && child instanceof DartVarDeclarationList) {
addFromVarDeclarationList(result, (DartVarDeclarationList) child);
} else if (child instanceof DartComponent) {
boolean isFieldOrVar = child instanceof DartVarAccessDeclaration || child instanceof DartVarDeclarationListPart;
if (!isFieldOrVar) {
result.add(((DartComponent) child).getComponentName());
}
}
}
return result;
}
use of gnu.trove.THashSet in project intellij-plugins by JetBrains.
the class CfmlComponentReference method buildVariants.
@NotNull
public static Object[] buildVariants(String text, PsiFile containingFile, final Project project, @Nullable CfmlComponentReference reference, final boolean forceQualify) {
Collection<Object> variants = new THashSet<>();
String directoryName = "";
if (text.contains(".")) {
int i = text.lastIndexOf(".");
directoryName = text.substring(0, i);
}
CfmlProjectConfiguration.State state = CfmlProjectConfiguration.getInstance(project).getState();
CfmlMappingsConfig mappings = state != null ? state.getMapps().clone() : new CfmlMappingsConfig();
adjustMappingsIfEmpty(mappings, project);
if (reference != null)
addFakeMappingsForImports(reference, mappings);
List<String> realPossiblePaths = mappings.mapVirtualToReal(directoryName);
for (String realPath : realPossiblePaths) {
addVariantsFromPath(variants, directoryName, realPath);
}
for (String value : mappings.getServerMappings().keySet()) {
if (value.startsWith(directoryName) && !value.isEmpty() && (StringUtil.startsWithChar(value, '/') || StringUtil.startsWithChar(value, '\\'))) {
variants.add(value.replace('\\', '.').replace('/', '.').substring(1));
}
}
containingFile = containingFile == null ? null : containingFile.getOriginalFile();
if (containingFile != null && containingFile instanceof CfmlFile) {
CfmlFile cfmlContainingFile = (CfmlFile) containingFile;
if (directoryName.length() == 0) {
PsiDirectory directory = cfmlContainingFile.getParent();
if (directory != null) {
addVariantsFromPath(variants, "", directory.getVirtualFile().getPresentableUrl());
}
} else {
String dirPath = cfmlContainingFile.getParent().getVirtualFile().getPath() + "/" + directoryName.replaceAll("[./]+", "/");
addVariantsFromPath(variants, directoryName, dirPath);
}
}
final String finalDirectoryName = directoryName;
return ContainerUtil.map2Array(variants, new Function<Object, Object>() {
class DotInsertHandler implements InsertHandler<LookupElement> {
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
Document document = context.getDocument();
int offset = context.getEditor().getCaretModel().getOffset();
document.insertString(offset, ".");
context.getEditor().getCaretModel().moveToOffset(offset + 1);
}
}
public Object fun(final Object object) {
if (object instanceof VirtualFile) {
VirtualFile element = (VirtualFile) object;
String elementNameWithoutExtension = element.getNameWithoutExtension();
String name = forceQualify ? finalDirectoryName + (finalDirectoryName.length() == 0 ? "" : ".") + elementNameWithoutExtension : elementNameWithoutExtension;
if (name.length() == 0)
name = element.getName();
if (element.isDirectory()) {
return LookupElementBuilder.create(name).withIcon(DIRECTORY_CLOSED_ICON).withInsertHandler(new DotInsertHandler()).withCaseSensitivity(false);
} else {
Icon icon = CLASS_ICON;
// choosing correct icon (class or interface)
if (CfmlIndex.getInstance(project).getComponentsByNameInScope(elementNameWithoutExtension, GlobalSearchScope.fileScope(project, element)).size() == 1) {
icon = CLASS_ICON;
} else if (CfmlIndex.getInstance(project).getInterfacesByNameInScope(elementNameWithoutExtension, GlobalSearchScope.fileScope(project, element)).size() == 1) {
icon = INTERFACE_ICON;
}
return LookupElementBuilder.create(name).withIcon(icon).withCaseSensitivity(false);
}
} else if (object instanceof String) {
return LookupElementBuilder.create((String) object).withInsertHandler(new DotInsertHandler()).withCaseSensitivity(false);
}
return object;
}
});
}
use of gnu.trove.THashSet in project intellij-plugins by JetBrains.
the class CompilerConfigGeneratorRt method addSourcePaths.
private void addSourcePaths(final Element rootElement) {
final String localeValue = getValueAndSource(CompilerOptionInfo.getOptionInfo("compiler.locale")).first;
final List<String> locales = StringUtil.split(localeValue, CompilerOptionInfo.LIST_ENTRIES_SEPARATOR);
// when adding source paths we respect locales set both in UI and in Additional compiler options
locales.addAll(FlexCommonUtils.getOptionValues(myProjectLevelCompilerOptions.getAdditionalOptions(), "locale", "compiler.locale"));
locales.addAll(FlexCommonUtils.getOptionValues(myModuleLevelCompilerOptions.getAdditionalOptions(), "locale", "compiler.locale"));
locales.addAll(FlexCommonUtils.getOptionValues(myBC.getCompilerOptions().getAdditionalOptions(), "locale", "compiler.locale"));
// Set - to avoid duplication of paths like "locale/{locale}"
final Set<String> sourcePathsWithLocaleToken = new THashSet<>();
final List<String> sourcePathsWithoutLocaleToken = new LinkedList<>();
for (JpsModuleSourceRoot srcRoot : myModule.getSourceRoots(JavaSourceRootType.SOURCE)) {
final String srcRootPath = JpsPathUtil.urlToPath(srcRoot.getUrl());
if (locales.contains(PathUtilRt.getFileName(srcRootPath))) {
sourcePathsWithLocaleToken.add(PathUtilRt.getParentPath(srcRootPath) + "/" + FlexCommonUtils.LOCALE_TOKEN);
} else {
sourcePathsWithoutLocaleToken.add(srcRootPath);
}
}
if (includeTestRoots()) {
for (JpsModuleSourceRoot srcRoot : myModule.getSourceRoots(JavaSourceRootType.TEST_SOURCE)) {
final String srcRootPath = JpsPathUtil.urlToPath(srcRoot.getUrl());
if (locales.contains(PathUtilRt.getFileName(srcRootPath))) {
sourcePathsWithLocaleToken.add(PathUtilRt.getParentPath(srcRootPath) + "/" + FlexCommonUtils.LOCALE_TOKEN);
} else {
sourcePathsWithoutLocaleToken.add(srcRootPath);
}
}
}
final StringBuilder sourcePathBuilder = new StringBuilder();
if (myCSS) {
final String cssFolderPath = PathUtilRt.getParentPath(myBC.getMainClass());
if (!sourcePathsWithoutLocaleToken.contains(cssFolderPath)) {
sourcePathBuilder.append(cssFolderPath);
}
}
for (final String sourcePath : sourcePathsWithLocaleToken) {
if (sourcePathBuilder.length() > 0) {
sourcePathBuilder.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR);
}
sourcePathBuilder.append(sourcePath);
}
for (final String sourcePath : sourcePathsWithoutLocaleToken) {
if (sourcePathBuilder.length() > 0) {
sourcePathBuilder.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR);
}
sourcePathBuilder.append(sourcePath);
}
addOption(rootElement, CompilerOptionInfo.SOURCE_PATH_INFO, sourcePathBuilder.toString());
}
use of gnu.trove.THashSet in project intellij-plugins by JetBrains.
the class AdtTask method appendANEPaths.
private static void appendANEPaths(final List<String> command, final Module module, final FlexBuildConfiguration bc) {
final Set<VirtualFile> extDirPaths = new THashSet<>();
for (VirtualFile aneFile : FlexCompilationUtils.getANEFiles(ModuleRootManager.getInstance(module), bc.getDependencies())) {
if (extDirPaths.add(aneFile.getParent())) {
command.add("-extdir");
command.add(FileUtil.toSystemDependentName(aneFile.getParent().getPath()));
}
}
}
use of gnu.trove.THashSet in project intellij-plugins by JetBrains.
the class AirPackageAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return;
final AirPackageDialog dialog = new AirPackageDialog(project);
if (!dialog.showAndGet()) {
return;
}
final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs = dialog.getSelectedBCs();
final Set<Module> modules = new THashSet<>();
for (Pair<Module, FlexBuildConfiguration> bc : modulesAndBCs) {
modules.add(bc.first);
}
final CompilerManager compilerManager = CompilerManager.getInstance(project);
final CompileScope compileScope = compilerManager.createModulesCompileScope(modules.toArray(new Module[modules.size()]), false);
FlexResourceBuildTargetScopeProvider.setBCsToCompileForPackaging(compileScope, modulesAndBCs);
compilerManager.make(compileScope, new CompileStatusNotification() {
public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
if (!aborted && errors == 0) {
createPackages(project, modulesAndBCs, dialog.getPasswords());
}
}
});
}
Aggregations