use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class EclipseImportBuilder method validate.
@Override
public boolean validate(final Project currentProject, final Project dstProject) {
final Ref<Exception> refEx = new Ref<>();
final Set<String> variables = new THashSet<>();
final Map<String, String> naturesNames = new THashMap<>();
final List<String> projectsToConvert = getParameters().projectsToConvert;
final boolean oneProjectToConvert = projectsToConvert.size() == 1;
final String separator = oneProjectToConvert ? "<br>" : ", ";
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
try {
for (String path : projectsToConvert) {
File classPathFile = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
if (classPathFile.exists()) {
EclipseClasspathReader.collectVariables(variables, JDOMUtil.load(classPathFile), path);
}
collectUnknownNatures(path, naturesNames, separator);
}
} catch (IOException | JDOMException e) {
refEx.set(e);
}
}, EclipseBundle.message("eclipse.import.converting"), false, currentProject);
if (!refEx.isNull()) {
Messages.showErrorDialog(dstProject, refEx.get().getMessage(), getTitle());
return false;
}
if (!ProjectMacrosUtil.checkNonIgnoredMacros(dstProject, variables)) {
return false;
}
if (!naturesNames.isEmpty()) {
final String title = "Unknown Natures Detected";
final String naturesByProject;
if (oneProjectToConvert) {
naturesByProject = naturesNames.values().iterator().next();
} else {
naturesByProject = StringUtil.join(naturesNames.keySet(), projectPath -> projectPath + "(" + naturesNames.get(projectPath) + ")", "<br>");
}
Notifications.Bus.notify(new Notification(title, title, "Imported projects contain unknown natures:<br>" + naturesByProject + "<br>" + "Some settings may be lost after import.", NotificationType.WARNING));
}
return true;
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class EclipseClasspathReader method readClasspath.
public void readClasspath(@NotNull ModifiableRootModel model, @NotNull Collection<String> unknownLibraries, @NotNull Collection<String> unknownJdks, Set<String> refsToModules, final String testPattern, Element classpathElement) throws IOException, ConversionException {
for (OrderEntry orderEntry : model.getOrderEntries()) {
if (!(orderEntry instanceof ModuleSourceOrderEntry)) {
model.removeOrderEntry(orderEntry);
}
}
int idx = 0;
EclipseModuleManagerImpl eclipseModuleManager = EclipseModuleManagerImpl.getInstance(model.getModule());
Set<String> libs = new THashSet<>();
for (Element o : classpathElement.getChildren(EclipseXml.CLASSPATHENTRY_TAG)) {
try {
readClasspathEntry(model, unknownLibraries, unknownJdks, refsToModules, testPattern, o, idx++, eclipseModuleManager, ((BasePathMacroManager) PathMacroManager.getInstance(model.getModule())).getExpandMacroMap(), libs);
} catch (ConversionException e) {
ErrorLog.rethrow(ErrorLog.Level.Warning, null, EclipseXml.CLASSPATH_FILE, e);
}
}
if (!model.isSdkInherited() && model.getSdkName() == null) {
eclipseModuleManager.setForceConfigureJDK();
model.inheritSdk();
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class UnInjectLanguageAction method defaultFunctionalityWorked.
private static boolean defaultFunctionalityWorked(final PsiLanguageInjectionHost host) {
final THashSet<String> languages = new THashSet<>();
final List<Pair<PsiElement, TextRange>> files = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host);
if (files == null)
return false;
for (Pair<PsiElement, TextRange> pair : files) {
for (Language lang = pair.first.getLanguage(); lang != null; lang = lang.getBaseLanguage()) {
languages.add(lang.getID());
}
}
// todo therefore this part doesn't work for java
return Configuration.getProjectInstance(host.getProject()).setHostInjectionEnabled(host, languages, false);
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class BuildOperations method initTargetFSState.
private static void initTargetFSState(CompileContext context, BuildTarget<?> target, final boolean forceMarkDirty) throws IOException {
final ProjectDescriptor pd = context.getProjectDescriptor();
final Timestamps timestamps = pd.timestamps.getStorage();
final THashSet<File> currentFiles = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
FSOperations.markDirtyFiles(context, target, CompilationRound.CURRENT, timestamps, forceMarkDirty, currentFiles, null);
// handle deleted paths
final BuildFSState fsState = pd.fsState;
fsState.clearDeletedPaths(target);
final SourceToOutputMapping sourceToOutputMap = pd.dataManager.getSourceToOutputMap(target);
for (final Iterator<String> it = sourceToOutputMap.getSourcesIterator(); it.hasNext(); ) {
final String path = it.next();
// can check if the file exists
final File file = new File(path);
if (!currentFiles.contains(file)) {
fsState.registerDeleted(context, target, file, timestamps);
}
}
pd.fsState.markInitialScanPerformed(target);
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class BuildOperations method cleanOutputsCorrespondingToChangedFiles.
public static <R extends BuildRootDescriptor, T extends BuildTarget<R>> Map<T, Set<File>> cleanOutputsCorrespondingToChangedFiles(final CompileContext context, DirtyFilesHolder<R, T> dirtyFilesHolder) throws ProjectBuildException {
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
try {
final Map<T, Set<File>> cleanedSources = new HashMap<>();
final THashSet<File> dirsToDelete = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
final Collection<String> deletedPaths = new ArrayList<>();
dirtyFilesHolder.processDirtyFiles(new FileProcessor<R, T>() {
// cache the mapping locally
private final Map<T, SourceToOutputMapping> mappingsCache = new HashMap<>();
private final TObjectIntHashMap<T> idsCache = new TObjectIntHashMap<>();
@Override
public boolean apply(T target, File file, R sourceRoot) throws IOException {
SourceToOutputMapping srcToOut = mappingsCache.get(target);
if (srcToOut == null) {
srcToOut = dataManager.getSourceToOutputMap(target);
mappingsCache.put(target, srcToOut);
}
final int targetId;
if (!idsCache.containsKey(target)) {
targetId = dataManager.getTargetsState().getBuildTargetId(target);
idsCache.put(target, targetId);
} else {
targetId = idsCache.get(target);
}
final String srcPath = file.getPath();
final Collection<String> outputs = srcToOut.getOutputs(srcPath);
if (outputs != null) {
final boolean shouldPruneOutputDirs = target instanceof ModuleBasedTarget;
final List<String> deletedForThisSource = new ArrayList<>(outputs.size());
for (String output : outputs) {
deleteRecursively(output, deletedForThisSource, shouldPruneOutputDirs ? dirsToDelete : null);
}
deletedPaths.addAll(deletedForThisSource);
dataManager.getOutputToTargetRegistry().removeMapping(deletedForThisSource, targetId);
Set<File> cleaned = cleanedSources.get(target);
if (cleaned == null) {
cleaned = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
cleanedSources.put(target, cleaned);
}
cleaned.add(file);
}
return true;
}
});
if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
final ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
if (logger.isEnabled()) {
logger.logDeletedFiles(deletedPaths);
}
}
if (!deletedPaths.isEmpty()) {
context.processMessage(new FileDeletedEvent(deletedPaths));
}
// attempting to delete potentially empty directories
FSOperations.pruneEmptyDirs(context, dirsToDelete);
return cleanedSources;
} catch (Exception e) {
throw new ProjectBuildException(e);
}
}
Aggregations