/** * Loads the specified stopwords file. Used internally by Stopwords(TermPipeline, String[]). * * @param stopwordsFilename The filename of the file to use as the stopwords list. */ public void loadStopwordsList(String stopwordsFilename) { // determine encoding to use when reading the stopwords files // String stopwordsEncoding = null; try { // use sys default encoding if none specified BufferedReader br = new BufferedReader(new FileReader(stopwordsFilename)); String word; while ((word = br.readLine()) != null) { word = word.trim(); if (word.length() > 0) { stopWords.add(word); } } br.close(); } catch (IOException ioe) { System.err.println( "Errror: Input/Output Exception while reading stopword list (" + stopwordsFilename + ") : Stack trace follows."); ioe.printStackTrace(); } if (stopWords.size() == 0) System.err.println("Error: Empty stopwords file was used (" + stopwordsFilename + ")"); }
public static void excludePackagesFolders( final Module module, final VirtualFile pubspecYamlFile) { final VirtualFile root = pubspecYamlFile.getParent(); final VirtualFile contentRoot = root == null ? null : ProjectRootManager.getInstance(module.getProject()) .getFileIndex() .getContentRootForFile(root); if (contentRoot == null) return; // http://pub.dartlang.org/doc/glossary.html#entrypoint-directory // Entrypoint directory: A directory inside your package that is allowed to contain Dart // entrypoints. // Pub will ensure all of these directories get a “packages” directory, which is needed for // “package:” imports to work. // Pub has a whitelist of these directories: benchmark, bin, example, test, tool, and web. // Any subdirectories of those (except bin) may also contain entrypoints. // // the same can be seen in the pub tool source code: [repo // root]/sdk/lib/_internal/pub/lib/src/entrypoint.dart final Collection<String> oldExcludedPackagesUrls = ContainerUtil.filter( ModuleRootManager.getInstance(module).getExcludeRootUrls(), new Condition<String>() { final String rootUrlPrefix = root.getUrl() + '/'; public boolean value(final String url) { if (!url.startsWith(rootUrlPrefix)) return false; if (url.endsWith("/packages")) return true; // excluded subfolder of 'packages' folder final int lastSlashIndex = url.lastIndexOf('/'); if (lastSlashIndex > 0 && url.substring(0, lastSlashIndex).endsWith("/packages")) return true; return false; } }); final THashSet<String> newExcludedPackagesUrls = collectFoldersToExclude(module, pubspecYamlFile); if (oldExcludedPackagesUrls.size() != newExcludedPackagesUrls.size() || !newExcludedPackagesUrls.containsAll(oldExcludedPackagesUrls)) { updateExcludedFolders(module, contentRoot, oldExcludedPackagesUrls, newExcludedPackagesUrls); } }
@NotNull @Override public Comparable weigh(@NotNull LookupElement element) { final Object object = element.getObject(); final String name = getLookupObjectName(object); if (name != null) { int max = 0; final List<String> wordsNoDigits = NameUtil.nameToWordsLowerCase(truncDigits(name)); for (ExpectedTypeInfo myExpectedInfo : myExpectedTypes) { String expectedName = ((ExpectedTypeInfoImpl) myExpectedInfo).getExpectedName().compute(); if (expectedName != null) { final THashSet<String> set = new THashSet<String>(NameUtil.nameToWordsLowerCase(truncDigits(expectedName))); set.retainAll(wordsNoDigits); max = Math.max(max, set.size()); } } return -max; } return 0; }
@Override @NotNull public String[] getNames(Project project, boolean includeNonProjectItems) { if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) { final THashSet<String> names = new THashSet<String>(1000); IdFilter filter = IdFilter.getProjectIdFilter(project, includeNonProjectItems); processNames( new Processor<String>() { @Override public boolean process(String s) { names.add(s); return true; } }, FindSymbolParameters.searchScopeFor(project, includeNonProjectItems), filter); if (IdFilter.LOG.isDebugEnabled()) { IdFilter.LOG.debug("All names retrieved2:" + names.size()); } return ArrayUtil.toStringArray(names); } else { return FilenameIndex.getAllFilenames(project); } }