@Override @NotNull public SuggestedNameInfo suggestUniqueVariableName( @NotNull final SuggestedNameInfo baseNameInfo, PsiElement place, boolean ignorePlaceName, boolean lookForward) { final String[] names = baseNameInfo.names; final LinkedHashSet<String> uniqueNames = new LinkedHashSet<String>(names.length); for (String name : names) { if (ignorePlaceName && place instanceof PsiNamedElement) { final String placeName = ((PsiNamedElement) place).getName(); if (Comparing.strEqual(placeName, name)) { uniqueNames.add(name); continue; } } uniqueNames.add(suggestUniqueVariableName(name, place, lookForward)); } return new SuggestedNameInfo(ArrayUtil.toStringArray(uniqueNames)) { @Override public void nameChosen(String name) { baseNameInfo.nameChosen(name); } }; }
/** * Test importing of Clinical Data File. * * @throws DaoException Database Access Error. * @throws IOException IO Error. */ @Test @Ignore("To be fixed") public void testImportClinicalDataSurvival() throws Exception { // TBD: change this to use getResourceAsStream() File clinicalFile = new File("target/test-classes/clinical_data.txt"); ImportClinicalData importClinicalData = new ImportClinicalData(study, clinicalFile); importClinicalData.importData(); LinkedHashSet<String> caseSet = new LinkedHashSet<String>(); caseSet.add("TCGA-A1-A0SB"); caseSet.add("TCGA-A1-A0SI"); caseSet.add("TCGA-A1-A0SE"); List<Patient> clinicalCaseList = DaoClinicalData.getSurvivalData(study.getInternalId(), caseSet); assertEquals(3, clinicalCaseList.size()); Patient clinical0 = clinicalCaseList.get(0); assertEquals(new Double(79.04), clinical0.getAgeAtDiagnosis()); assertEquals("DECEASED", clinical0.getOverallSurvivalStatus()); assertEquals("Recurred/Progressed", clinical0.getDiseaseFreeSurvivalStatus()); assertEquals(new Double(43.8), clinical0.getOverallSurvivalMonths()); assertEquals(new Double(15.05), clinical0.getDiseaseFreeSurvivalMonths()); Patient clinical1 = clinicalCaseList.get(1); assertEquals(new Double(55.53), clinical1.getAgeAtDiagnosis()); assertEquals("LIVING", clinical1.getOverallSurvivalStatus()); assertEquals("DiseaseFree", clinical1.getDiseaseFreeSurvivalStatus()); assertEquals(new Double(49.02), clinical1.getOverallSurvivalMonths()); assertEquals(new Double(49.02), clinical1.getDiseaseFreeSurvivalMonths()); Patient clinical2 = clinicalCaseList.get(2); assertEquals(null, clinical2.getDiseaseFreeSurvivalMonths()); }
/** * Insert the method's description here. Creation date: (21.12.2000 22:24:23) * * @return boolean * @param object com.cosylab.vdct.graphics.objects.VisibleObject * @param zoomOnHilited sets the option whether the hilited object should be zoomed in */ public boolean setAsHilited(VisibleObject object, boolean zoomOnHilited) { this.zoomOnHilited = zoomOnHilited; if (zoomOnHilited) { DrawingSurface.getInstance().repaint(); hilitedObjects.clear(); if (hilitedObject != null) { hilitedObjects.add(hilitedObject); } } if (object == null) { hilitedObjects.clear(); hilitedObject = null; return false; } if (object != hilitedObject || hilitedObjects.size() == 1) { hilitedObject = object; // initialization hilitedObjects.clear(); hilitedObjects.add(hilitedObject); Object obj = hilitedObject; // inlinks Vector outlinks = null; if (obj instanceof MultiInLink) { outlinks = ((MultiInLink) obj).getOutlinks(); } else if (obj instanceof InLink) { outlinks = new Vector(); outlinks.add(((InLink) obj).getOutput()); } if (!zoomOnHilited) { if (outlinks != null) for (int i = 0; i < outlinks.size(); i++) { obj = outlinks.elementAt(i); hilitedObjects.add(obj); while (obj instanceof InLink) { obj = ((InLink) obj).getOutput(); hilitedObjects.add(obj); } } // outLinks obj = hilitedObject; while (obj instanceof OutLink) { obj = ((OutLink) obj).getInput(); hilitedObjects.add(obj); } } return true; } else return false; }
public LinkedHashSet<Path> scan(FileSystem fs, Path filePath, Set<String> consumedFiles) { LinkedHashSet<Path> pathSet = Sets.newLinkedHashSet(); try { LOG.debug("Scanning {} with pattern {}", filePath, this.filePatternRegexp); FileStatus[] files = fs.listStatus(filePath); for (FileStatus status : files) { Path path = status.getPath(); String filePathStr = path.toString(); if (consumedFiles.contains(filePathStr)) { continue; } if (ignoredFiles.contains(filePathStr)) { continue; } if (acceptFile(filePathStr)) { LOG.debug("Found {}", filePathStr); pathSet.add(path); } else { // don't look at it again ignoredFiles.add(filePathStr); } } } catch (FileNotFoundException e) { LOG.warn("Failed to list directory {}", filePath, e); } catch (IOException e) { throw new RuntimeException(e); } return pathSet; }
@Override public void loadState(Element state) { final List<Element> abbreviations = state.getChildren("abbreviations"); if (abbreviations != null && abbreviations.size() == 1) { final List<Element> actions = abbreviations.get(0).getChildren("action"); if (actions != null && actions.size() > 0) { for (Element action : actions) { final String actionId = action.getAttributeValue("id"); LinkedHashSet<String> values = myActionId2Abbreviations.get(actionId); if (values == null) { values = new LinkedHashSet<String>(1); myActionId2Abbreviations.put(actionId, values); } final List<Element> abbreviation = action.getChildren("abbreviation"); if (abbreviation != null) { for (Element abbr : abbreviation) { final String abbrValue = abbr.getAttributeValue("name"); if (abbrValue != null) { values.add(abbrValue); } } } } } } }
public String[] getGroupNames() { LinkedHashSet<String> groups = new LinkedHashSet<String>(); for (ApiDoc apiDoc : docs) { groups.add(apiDoc.group); } return groups.toArray(new String[groups.size()]); }
public static LinkedHashSet<String> findJars(LogicalPlan dag, Class<?>[] defaultClasses) { List<Class<?>> jarClasses = new ArrayList<Class<?>>(); for (String className : dag.getClassNames()) { try { Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className); jarClasses.add(clazz); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Failed to load class " + className, e); } } for (Class<?> clazz : Lists.newArrayList(jarClasses)) { // process class and super classes (super does not require deploy annotation) for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass()) { // LOG.debug("checking " + c); jarClasses.add(c); jarClasses.addAll(Arrays.asList(c.getInterfaces())); } } jarClasses.addAll(Arrays.asList(defaultClasses)); if (dag.isDebug()) { LOG.debug("Deploy dependencies: {}", jarClasses); } LinkedHashSet<String> localJarFiles = new LinkedHashSet<String>(); // avoid duplicates HashMap<String, String> sourceToJar = new HashMap<String, String>(); for (Class<?> jarClass : jarClasses) { if (jarClass.getProtectionDomain().getCodeSource() == null) { // system class continue; } String sourceLocation = jarClass.getProtectionDomain().getCodeSource().getLocation().toString(); String jar = sourceToJar.get(sourceLocation); if (jar == null) { // don't create jar file from folders multiple times jar = JarFinder.getJar(jarClass); sourceToJar.put(sourceLocation, jar); LOG.debug("added sourceLocation {} as {}", sourceLocation, jar); } if (jar == null) { throw new AssertionError("Cannot resolve jar file for " + jarClass); } localJarFiles.add(jar); } String libJarsPath = dag.getValue(LogicalPlan.LIBRARY_JARS); if (!StringUtils.isEmpty(libJarsPath)) { String[] libJars = StringUtils.splitByWholeSeparator(libJarsPath, LIB_JARS_SEP); localJarFiles.addAll(Arrays.asList(libJars)); } LOG.info("Local jar file dependencies: " + localJarFiles); return localJarFiles; }
public static LinkedHashSet<String> sortMatching( final PrefixMatcher matcher, Collection<String> _names) { ProgressManager.checkCanceled(); List<String> sorted = new ArrayList<String>(); for (String name : _names) { if (matcher.prefixMatches(name)) { sorted.add(name); } } ProgressManager.checkCanceled(); Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER); ProgressManager.checkCanceled(); LinkedHashSet<String> result = new LinkedHashSet<String>(); for (String name : sorted) { if (matcher.isStartMatch(name)) { result.add(name); } } ProgressManager.checkCanceled(); result.addAll(sorted); return result; }
public static void main(String[] args) throws Exception { ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("c:\\test.dat")); LinkedHashSet<String> set1 = new LinkedHashSet<String>(); set1.add("New York"); LinkedHashSet<String> set2 = (LinkedHashSet<String>) set1.clone(); set1.add("Atlanta"); output.writeObject(set1); output.writeObject(set2); output.close(); ObjectInputStream input = new ObjectInputStream(new FileInputStream("c:\\test.dat")); set1 = (LinkedHashSet) input.readObject(); set2 = (LinkedHashSet) input.readObject(); System.out.println(set1); System.out.println(set2); output.close(); }
public static Set<PsiType> getDefaultExpectedTypes(@NotNull GrExpression element) { final LinkedHashSet<PsiType> result = new LinkedHashSet<PsiType>(); for (TypeConstraint constraint : calculateTypeConstraints(element)) { result.add(constraint.getDefaultType()); } return result; }
public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) { data.TEST_OBJECT = TestType.PATTERN.getType(); final String suffix; if (method != null) { data.METHOD_NAME = method.getName(); suffix = "," + data.METHOD_NAME; } else { suffix = ""; } LinkedHashSet<String> patterns = new LinkedHashSet<String>(); for (PsiClass pattern : classes) { patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + suffix); } data.setPatterns(patterns); final Module module = RunConfigurationProducer.getInstance(TestNGPatternConfigurationProducer.class) .findModule(this, getConfigurationModule().getModule(), patterns); if (module == null) { data.setScope(TestSearchScope.WHOLE_PROJECT); setModule(null); } else { setModule(module); } setGeneratedName(); }
/** * Begins the in-place refactoring operation. * * @return true if the in-place refactoring was successfully started, false if it failed to start * and a dialog should be shown instead. */ public boolean startInplaceIntroduceTemplate() { final boolean replaceAllOccurrences = isReplaceAllOccurrences(); final Ref<Boolean> result = new Ref<>(); CommandProcessor.getInstance() .executeCommand( myProject, () -> { final String[] names = suggestNames(replaceAllOccurrences, getLocalVariable()); final V variable = createFieldToStartTemplateOn(replaceAllOccurrences, names); boolean started = false; if (variable != null) { int caretOffset = getCaretOffset(); myEditor.getCaretModel().moveToOffset(caretOffset); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); final LinkedHashSet<String> nameSuggestions = new LinkedHashSet<>(); nameSuggestions.add(variable.getName()); nameSuggestions.addAll(Arrays.asList(names)); initOccurrencesMarkers(); setElementToRename(variable); updateTitle(getVariable()); started = super.performInplaceRefactoring(nameSuggestions); if (started) { onRenameTemplateStarted(); myDocumentAdapter = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { if (myPreview == null) return; final TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor); if (templateState != null) { final TextResult value = templateState.getVariableValue( InplaceRefactoring.PRIMARY_VARIABLE_NAME); if (value != null) { updateTitle(getVariable(), value.getText()); } } } }; myEditor.getDocument().addDocumentListener(myDocumentAdapter); updateTitle(getVariable()); if (TemplateManagerImpl.getTemplateState(myEditor) != null) { myEditor.putUserData(ACTIVE_INTRODUCE, this); } } } result.set(started); if (!started) { finish(true); } }, getCommandName(), getCommandName()); return result.get(); }
private static void traverseDescriptors( InspectionTreeNode node, LinkedHashSet<CommonProblemDescriptor> descriptors) { if (node instanceof ProblemDescriptionNode) { descriptors.add(((ProblemDescriptionNode) node).getDescriptor()); } for (int i = node.getChildCount() - 1; i >= 0; i--) { traverseDescriptors((InspectionTreeNode) node.getChildAt(i), descriptors); } }
public void register( String abbreviation, String actionId, Map<String, LinkedHashSet<String>> storage) { LinkedHashSet<String> abbreviations = storage.get(actionId); if (abbreviations == null) { abbreviations = new LinkedHashSet<String>(1); storage.put(actionId, abbreviations); } abbreviations.add(abbreviation); }
private static void addCurrentlySelectedItemToTop( Lookup lookup, List<LookupElement> items, LinkedHashSet<LookupElement> model) { if (!lookup.isSelectionTouched()) { LookupElement lastSelection = lookup.getCurrentItem(); if (ContainerUtil.indexOfIdentity(items, lastSelection) >= 0) { model.add(lastSelection); } } }
private void registerStaticColumns() { for (Tuple<String, DataType> column : staticColumns) { ReferenceInfo info = new ReferenceInfo( new ReferenceIdent(ident(), column.v1(), null), RowGranularity.DOC, column.v2()); if (info.ident().isColumn()) { columns.add(info); } INFOS.put(info.ident().columnIdent(), info); } }
LinkedHashSet<EqClass> getNonTrivialEqClasses() { if (myCachedNonTrivialEqClasses != null) return myCachedNonTrivialEqClasses; LinkedHashSet<EqClass> result = ContainerUtil.newLinkedHashSet(); for (EqClass eqClass : myEqClasses) { if (eqClass != null && eqClass.size() > 1) { result.add(eqClass); } } return myCachedNonTrivialEqClasses = result; }
private static void addSomeItems( LinkedHashSet<LookupElement> model, Iterator<LookupElement> iterator, Condition<LookupElement> stopWhen) { while (iterator.hasNext()) { LookupElement item = iterator.next(); model.add(item); if (stopWhen.value(item)) { break; } } }
public final void a(ajy paramajy, boolean paramBoolean) { if (paramBoolean) { K.add(paramajy); } for (;;) { A(); return; K.remove(paramajy); } }
private String constructAmendedMessage() { Set<VirtualFile> selectedRoots = getVcsRoots(getSelectedFilePaths()); // get only selected files LinkedHashSet<String> messages = ContainerUtil.newLinkedHashSet(); if (myMessagesForRoots != null) { for (VirtualFile root : selectedRoots) { String message = myMessagesForRoots.get(root); if (message != null) { messages.add(message); } } } return DvcsUtil.joinMessagesOrNull(messages); }
private static void findSourceFiles(LinkedHashSet<String> files, String file) { File f = new File(file); if (f.isFile()) { String ext = FilenameUtils.getExtension(f.getName()); if ("java".equalsIgnoreCase(ext)) files.add(file); } else if (f.isDirectory()) { for (String sub : f.list()) { if (sub.equals(".") || sub.equals("..")) continue; findSourceFiles(files, FilenameUtils.concat(f.getAbsolutePath(), sub)); } } }
private static LinkedHashSet getProvidersNotUsingCache( String serviceName, String algName, String attrName, String filterValue, Provider[] allProviders) { LinkedHashSet candidates = new LinkedHashSet(5); for (int i = 0; i < allProviders.length; i++) { if (isCriterionSatisfied(allProviders[i], serviceName, algName, attrName, filterValue)) { candidates.add(allProviders[i]); } } return candidates; }
public static LinkedHashSet<String> getLangs(HttpExchange t) { String hdr = t.getRequestHeaders().getFirst("Accept-language"); LinkedHashSet<String> result = new LinkedHashSet<>(); if (StringUtils.isEmpty(hdr)) { return result; } String[] tmp = hdr.split(","); for (String language : tmp) { String[] l1 = language.split(";"); result.add(l1[0]); } return result; }
public synchronized void addTaskAttempt(int volumeId, TaskAttempt attemptId) { synchronized (unassignedTaskForEachVolume) { LinkedHashSet<TaskAttempt> list = unassignedTaskForEachVolume.get(volumeId); if (list == null) { list = new LinkedHashSet<>(); unassignedTaskForEachVolume.put(volumeId, list); } list.add(attemptId); } remainTasksNum.incrementAndGet(); if (!diskVolumeLoads.containsKey(volumeId)) diskVolumeLoads.put(volumeId, 0); }
// recursively initialize nodeDests from start node private void initNodeDests(SeqPhase phase, SeqNode n) throws Xcept { if (nodeDests.get(n) != null) return; if (stopAtFFTs && n.fft() != null) return; LinkedHashSet<SeqNode> dests = new LinkedHashSet<SeqNode>(); nodeDests.put(n, dests); Iterator<SeqEdge> es = graph.getEdgesFrom(n); while (es.hasNext()) { SeqEdge e = es.next(); SeqNode n1 = e.dest(); dests.add(n1); if (phase != graph.getPhase(n1)) continue; if (stopAtFFTs && n1.fft() != null) continue; initNodeDests(phase, n1); } }
@Nullable public String getDefaultMessageFor(FilePath[] filesToCheckin) { LinkedHashSet<String> messages = ContainerUtil.newLinkedHashSet(); for (VirtualFile root : GitUtil.gitRoots(Arrays.asList(filesToCheckin))) { VirtualFile mergeMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_MERGE_MSG); VirtualFile squashMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_SQUASH_MSG); try { if (mergeMsg == null && squashMsg == null) { continue; } String encoding = GitConfigUtil.getCommitEncoding(myProject, root); if (mergeMsg != null) { messages.add(loadMessage(mergeMsg, encoding)); } else { messages.add(loadMessage(squashMsg, encoding)); } } catch (IOException e) { if (log.isDebugEnabled()) { log.debug("Unable to load merge message", e); } } } return DvcsUtil.joinMessagesOrNull(messages); }
/** {@inheritDoc} */ @Override public ConfigChangeResult applyConfigurationChange(BackupBackendCfg cfg) { ResultCode resultCode = ResultCode.SUCCESS; boolean adminActionRequired = false; ArrayList<Message> messages = new ArrayList<Message>(); Set<String> values = cfg.getBackupDirectory(); backupDirectories = new LinkedHashSet<File>(values.size()); for (String s : values) { backupDirectories.add(getFileForPath(s)); } currentConfig = cfg; return new ConfigChangeResult(resultCode, adminActionRequired, messages); }
public void moveFieldInitializations() throws IncorrectOperationException { LOG.assertTrue(myMembersAfterMove != null); final LinkedHashSet<PsiField> movedFields = new LinkedHashSet<>(); for (PsiMember member : myMembersAfterMove) { if (member instanceof PsiField) { movedFields.add((PsiField) member); } } if (movedFields.isEmpty()) return; PullUpHelper<MemberInfo> processor = getProcessor(myTargetSuperClass); LOG.assertTrue(processor != null, myTargetSuperClass); processor.moveFieldInitializations(movedFields); }
public static BridgeInvocation_c[] getManyACT_BRGsOnR628( ActualParameter_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new BridgeInvocation_c[0]; LinkedHashSet<BridgeInvocation_c> elementsSet = new LinkedHashSet<BridgeInvocation_c>(); for (int i = 0; i < targets.length; i++) { BridgeInvocation_c associate = targets[i].BridgeInvocation; if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) { if (elementsSet.add(associate)) {} } } BridgeInvocation_c[] result = new BridgeInvocation_c[elementsSet.size()]; elementsSet.toArray(result); return result; }
public static ComponentResultSet_c[] getManyPE_CRSsOnR8008( ComponentVisibility_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new ComponentResultSet_c[0]; LinkedHashSet<ComponentResultSet_c> elementsSet = new LinkedHashSet<ComponentResultSet_c>(); for (int i = 0; i < targets.length; i++) { ComponentResultSet_c associate = targets[i].MakesUpAComponentResultSet; if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) { if (elementsSet.add(associate)) {} } } ComponentResultSet_c[] result = new ComponentResultSet_c[elementsSet.size()]; elementsSet.toArray(result); return result; }