private void handleBranchingInstruction(
     ProblemsHolder holder,
     StandardInstructionVisitor visitor,
     Set<Instruction> trueSet,
     Set<Instruction> falseSet,
     HashSet<PsiElement> reportedAnchors,
     BranchingInstruction instruction,
     final boolean onTheFly) {
   PsiElement psiAnchor = instruction.getPsiAnchor();
   boolean underBinary = isAtRHSOfBooleanAnd(psiAnchor);
   if (instruction instanceof InstanceofInstruction
       && visitor.isInstanceofRedundant((InstanceofInstruction) instruction)) {
     if (visitor.canBeNull((BinopInstruction) instruction)) {
       holder.registerProblem(
           psiAnchor,
           InspectionsBundle.message("dataflow.message.redundant.instanceof"),
           new RedundantInstanceofFix());
     } else {
       final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(psiAnchor, true);
       holder.registerProblem(
           psiAnchor,
           InspectionsBundle.message(
               underBinary
                   ? "dataflow.message.constant.condition.when.reached"
                   : "dataflow.message.constant.condition",
               Boolean.toString(true)),
           localQuickFix == null ? null : new LocalQuickFix[] {localQuickFix});
     }
   } else if (psiAnchor instanceof PsiSwitchLabelStatement) {
     if (falseSet.contains(instruction)) {
       holder.registerProblem(
           psiAnchor, InspectionsBundle.message("dataflow.message.unreachable.switch.label"));
     }
   } else if (psiAnchor != null
       && !reportedAnchors.contains(psiAnchor)
       && !isFlagCheck(psiAnchor)) {
     boolean evaluatesToTrue = trueSet.contains(instruction);
     final PsiElement parent = psiAnchor.getParent();
     if (parent instanceof PsiAssignmentExpression
         && ((PsiAssignmentExpression) parent).getLExpression() == psiAnchor) {
       holder.registerProblem(
           psiAnchor,
           InspectionsBundle.message(
               "dataflow.message.pointless.assignment.expression",
               Boolean.toString(evaluatesToTrue)),
           createConditionalAssignmentFixes(
               evaluatesToTrue, (PsiAssignmentExpression) parent, onTheFly));
     } else if (!skipReportingConstantCondition(visitor, psiAnchor, evaluatesToTrue)) {
       final LocalQuickFix fix = createSimplifyBooleanExpressionFix(psiAnchor, evaluatesToTrue);
       String message =
           InspectionsBundle.message(
               underBinary
                   ? "dataflow.message.constant.condition.when.reached"
                   : "dataflow.message.constant.condition",
               Boolean.toString(evaluatesToTrue));
       holder.registerProblem(psiAnchor, message, fix == null ? null : new LocalQuickFix[] {fix});
     }
     reportedAnchors.add(psiAnchor);
   }
 }
 /**
  * Generate new configuration name basing on descriptor
  *
  * @return the generated configuration name
  */
 private String generateNewConfigurationName() {
   String name = null;
   for (BranchDescriptor d : myBranches) {
     if (d.newBranchName != null) {
       name = d.newBranchName;
       break;
     }
     if (d.existingBranches.contains(d.currentReference)) {
       name = d.currentReference;
     }
   }
   if (name == null) {
     name = "untitled";
   }
   if (myExistingConfigNames.contains(name)) {
     for (int i = 2; i < Integer.MAX_VALUE; i++) {
       String t = name + i;
       if (!myExistingConfigNames.contains(t)) {
         name = t;
         break;
       }
     }
   }
   return name;
 }
 public boolean isDirectTransferInProgress(final FrostUploadItem ulItem) {
   final String id = ulItem.getGqIdentifier();
   if (directPUTsInProgress.contains(id)) {
     return true;
   }
   if (directPUTsWithoutAnswer.contains(id)) {
     return true;
   }
   return false;
 }
 @Nullable
 private FrameworkSupportNode createNode(
     final FrameworkSupportInModuleProvider provider,
     final Map<String, FrameworkSupportNode> nodes,
     final Map<FrameworkGroup<?>, FrameworkGroupNode> groupNodes,
     List<FrameworkSupportNodeBase> roots,
     List<FrameworkSupportInModuleProvider> providers,
     Set<String> associated,
     Map<String, FrameworkSupportNodeBase> associatedNodes) {
   String id = provider.getFrameworkType().getId();
   FrameworkSupportNode node = nodes.get(id);
   if (node != null || associatedNodes.containsKey(id)) {
     return node;
   }
   String underlyingTypeId = provider.getFrameworkType().getUnderlyingFrameworkTypeId();
   FrameworkSupportNodeBase parentNode = null;
   final FrameworkGroup<?> group = provider.getFrameworkType().getParentGroup();
   if (underlyingTypeId != null) {
     FrameworkSupportInModuleProvider parentProvider =
         FrameworkSupportUtil.findProvider(underlyingTypeId, providers);
     if (parentProvider == null) {
       LOG.info("Cannot find id = " + underlyingTypeId);
       return null;
     }
     parentNode =
         createNode(
             parentProvider, nodes, groupNodes, roots, providers, associated, associatedNodes);
   } else if (group != null) {
     parentNode = groupNodes.get(group);
     if (parentNode == null) {
       FrameworkGroupNode groupNode = new FrameworkGroupNode(group, null);
       if (associated.contains(groupNode.getId())) {
         associatedNodes.put(groupNode.getId(), groupNode);
       } else {
         groupNodes.put(group, groupNode);
         parentNode = groupNode;
         roots.add(groupNode);
       }
     }
   }
   node = new FrameworkSupportNode(provider, parentNode, myModel, this);
   if (associated.contains(id)) {
     associatedNodes.put(id, node);
   } else {
     nodes.put(id, node);
     if (parentNode == null) {
       roots.add(node);
     }
   }
   return node;
 }
示例#5
0
 /**
  * This method inserts a default value for the standard java types, else it inserts the text name
  * of the expected class type. It acts to give a clue as to the input type.
  */
 public static String getDefaultValue(String type) {
   if (numericalTypes.contains(type) || extraNumericalTypes.contains(type)) {
     return "0";
   }
   if (booleanTypes.contains(type)) {
     return "true";
   }
   type = getReadableClassName(type);
   int i = type.lastIndexOf('.');
   if (i > 0) {
     return type.substring(i + 1, type.length());
   } else {
     return type;
   }
 }
  private void addCondition(@NotNull ArrangementUiComponent component) {
    mySkipStateChange = true;
    try {
      component.setSelected(true);
      Collection<Set<ArrangementSettingsToken>> mutexes = mySettingsManager.getMutexes();

      // Update 'mutex conditions', i.e. conditions which can't be active at the same time (e.g.
      // type 'field' and type 'method').
      for (Set<ArrangementSettingsToken> mutex : mutexes) {
        if (!mutex.contains(component.getToken())) {
          continue;
        }
        for (ArrangementSettingsToken key : mutex) {
          if (key.equals(component.getToken())) {
            continue;
          }
          ArrangementUiComponent c = myComponents.get(key);
          if (c != null && c.isEnabled()) {
            removeCondition(c);
          }
        }
      }
      refreshConditions();
    } finally {
      mySkipStateChange = false;
    }
  }
  @Nullable
  public FilteringTreeStructure.FilteringNode selectPsiElement(PsiElement element) {
    Set<PsiElement> parents = getAllParents(element);

    FilteringTreeStructure.FilteringNode node =
        (FilteringTreeStructure.FilteringNode) myAbstractTreeBuilder.getRootElement();
    while (node != null) {
      boolean changed = false;
      for (FilteringTreeStructure.FilteringNode n : node.children()) {
        final PsiElement psiElement = getPsi(n);
        if (psiElement != null && parents.contains(psiElement)) {
          node = n;
          changed = true;
          break;
        }
      }
      if (!changed) {
        myAbstractTreeBuilder.select(node);
        if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) {
          TreeUtil.selectFirstNode(myTree);
        }
        myInitialNodeIsLeaf = node.getChildren().length == 0;
        return node;
      }
    }
    TreeUtil.selectFirstNode(myTree);
    return null;
  }
  void doAddAction(AnActionButton button) {
    if (isUnknown()) {
      return;
    }

    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BeforeRunTaskProvider<BeforeRunTask>[] providers =
        Extensions.getExtensions(
            BeforeRunTaskProvider.EXTENSION_POINT_NAME, myRunConfiguration.getProject());
    Set<Key> activeProviderKeys = getActiveProviderKeys();

    DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
    for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
      if (provider.createTask(myRunConfiguration) == null) continue;
      if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton()) continue;
      AnAction providerAction =
          new AnAction(provider.getName(), null, provider.getIcon()) {
            @Override
            public void actionPerformed(AnActionEvent e) {
              BeforeRunTask task = provider.createTask(myRunConfiguration);
              if (task != null) {
                provider.configureTask(myRunConfiguration, task);
                if (!provider.canExecuteTask(myRunConfiguration, task)) return;
              } else {
                return;
              }
              task.setEnabled(true);

              Set<RunConfiguration> configurationSet = new HashSet<RunConfiguration>();
              getAllRunBeforeRuns(task, configurationSet);
              if (configurationSet.contains(myRunConfiguration)) {
                JOptionPane.showMessageDialog(
                    BeforeRunStepsPanel.this,
                    ExecutionBundle.message(
                        "before.launch.panel.cyclic_dependency_warning",
                        myRunConfiguration.getName(),
                        provider.getDescription(task)),
                    ExecutionBundle.message("warning.common.title"),
                    JOptionPane.WARNING_MESSAGE);
                return;
              }
              addTask(task);
              myListener.fireStepsBeforeRunChanged();
            }
          };
      actionGroup.add(providerAction);
    }
    final ListPopup popup =
        popupFactory.createActionGroupPopup(
            ExecutionBundle.message("add.new.run.configuration.acrtion.name"),
            actionGroup,
            SimpleDataContext.getProjectContext(myRunConfiguration.getProject()),
            false,
            false,
            false,
            null,
            -1,
            Condition.TRUE);
    popup.show(button.getPreferredPopupPoint());
  }
示例#9
0
  /** Checks if a message should be passed up, or not */
  protected boolean shouldDropUpMessage(
      @SuppressWarnings("UnusedParameters") Message msg, Address sender) {
    if (discard_all && !sender.equals(localAddress())) return true;

    if (ignoredMembers.contains(sender)) {
      if (log.isTraceEnabled()) log.trace(localAddress + ": dropping message from " + sender);
      num_up++;
      return true;
    }

    if (up > 0) {
      double r = Math.random();
      if (r < up) {
        if (excludeItself && sender.equals(localAddress())) {
          if (log.isTraceEnabled()) log.trace("excluding myself");
        } else {
          if (log.isTraceEnabled()) log.trace(localAddress + ": dropping message from " + sender);
          num_up++;
          return true;
        }
      }
    }

    return false;
  }
示例#10
0
 public void registerStringValueAction(String key, ValueCallback<String> callback) {
   synchronized (lock) {
     if (keys.contains(key)) throw new IllegalStateException("Already registered: " + key);
     keys.add(key);
     actions.add(new StringActionPair(key, callback));
   }
 }
 /** Verify dialog state */
 private void verify() {
   String text = myNameTextField.getText().trim();
   if (text.length() == 0) {
     setError("Empty configuration name is not allowed.");
     return;
   } else if (myTarget != null && text.equals(myTarget.getName())) {
   } else if (myExistingConfigNames.contains(text)) {
     setError("There is another configuration with the same name");
     return;
   }
   for (BranchDescriptor d : myBranches) {
     switch (d.status) {
       case BRANCH_NAME_EXISTS:
         setError("Duplicate branch name for root " + d.getRoot());
         return;
       case INVALID_BRANCH_NAME:
         setError("Invalid branch name for root " + d.getRoot());
         return;
       case BAD_REVISION:
         setError("Invalid revision for root " + d.getRoot());
         return;
       case MISSING_REVISION:
         setError("The revision must be specified for root " + d.getRoot());
         return;
       case CHECKOUT_NEEDED:
       case NO_ACTION:
       case REMOVED_ROOT:
         break;
       default:
         throw new RuntimeException("Unexpected status: " + d.status);
     }
   }
   setError(null);
 }
  private static void updateExistingPluginInfo(
      IdeaPluginDescriptor descr, IdeaPluginDescriptor existing) {
    int state = StringUtil.compareVersionNumbers(descr.getVersion(), existing.getVersion());
    final PluginId pluginId = existing.getPluginId();
    final String idString = pluginId.getIdString();
    final JDOMExternalizableStringList installedPlugins =
        PluginManagerUISettings.getInstance().getInstalledPlugins();
    if (!installedPlugins.contains(idString)
        && !((IdeaPluginDescriptorImpl) existing).isDeleted()) {
      installedPlugins.add(idString);
    }
    final PluginManagerUISettings updateSettings = PluginManagerUISettings.getInstance();
    if (state > 0
        && !PluginManager.isIncompatible(descr)
        && !updatedPlugins.contains(descr.getPluginId())) {
      NewVersions2Plugins.put(pluginId, 1);
      if (!updateSettings.myOutdatedPlugins.contains(idString)) {
        updateSettings.myOutdatedPlugins.add(idString);
      }

      final IdeaPluginDescriptorImpl plugin = (IdeaPluginDescriptorImpl) existing;
      plugin.setDownloadsCount(descr.getDownloads());
      plugin.setVendor(descr.getVendor());
      plugin.setVendorEmail(descr.getVendorEmail());
      plugin.setVendorUrl(descr.getVendorUrl());
      plugin.setUrl(descr.getUrl());

    } else {
      updateSettings.myOutdatedPlugins.remove(idString);
      if (NewVersions2Plugins.remove(pluginId) != null) {
        updatedPlugins.add(pluginId);
      }
    }
  }
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    IdeaPluginDescriptor[] selection = getPluginTable().getSelectedObjects();
    boolean enabled = (selection != null);

    if (enabled) {
      for (IdeaPluginDescriptor descr : selection) {
        presentation.setText(IdeBundle.message("action.download.and.install.plugin"));
        presentation.setDescription(IdeBundle.message("action.download.and.install.plugin"));
        enabled &= !ourInstallingNodes.contains(descr);
        if (descr instanceof PluginNode) {
          enabled &= !PluginManagerColumnInfo.isDownloaded((PluginNode) descr);
          if (((PluginNode) descr).getStatus() == PluginNode.STATUS_INSTALLED) {
            presentation.setText(IdeBundle.message("action.update.plugin"));
            presentation.setDescription(IdeBundle.message("action.update.plugin"));
            enabled &= ourState.hasNewerVersion(descr.getPluginId());
          }
        } else if (descr instanceof IdeaPluginDescriptorImpl) {
          presentation.setText(IdeBundle.message("action.update.plugin"));
          presentation.setDescription(IdeBundle.message("action.update.plugin"));
          PluginId id = descr.getPluginId();
          enabled = enabled && ourState.hasNewerVersion(id);
        }
      }
    }

    presentation.setEnabled(enabled);
  }
  @Override
  public void saveAllDocuments() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myMultiCaster.beforeAllDocumentsSaving();
    if (myUnsavedDocuments.isEmpty()) return;

    final Map<Document, IOException> failedToSave = new HashMap<Document, IOException>();
    final Set<Document> vetoed = new HashSet<Document>();
    while (true) {
      int count = 0;

      for (Document document : myUnsavedDocuments) {
        if (failedToSave.containsKey(document)) continue;
        if (vetoed.contains(document)) continue;
        try {
          doSaveDocument(document);
        } catch (IOException e) {
          //noinspection ThrowableResultOfMethodCallIgnored
          failedToSave.put(document, e);
        } catch (SaveVetoException e) {
          vetoed.add(document);
        }
        count++;
      }

      if (count == 0) break;
    }

    if (!failedToSave.isEmpty()) {
      handleErrorsOnSave(failedToSave);
    }
  }
  private void doSaveDocument(@NotNull final Document document)
      throws IOException, SaveVetoException {
    VirtualFile file = getFile(document);

    if (file == null
        || file instanceof LightVirtualFile
        || file.isValid() && !isFileModified(file)) {
      removeFromUnsaved(document);
      return;
    }

    if (file.isValid() && needsRefresh(file)) {
      file.refresh(false, false);
      if (!myUnsavedDocuments.contains(document)) return;
    }

    for (FileDocumentSynchronizationVetoer vetoer :
        Extensions.getExtensions(FileDocumentSynchronizationVetoer.EP_NAME)) {
      if (!vetoer.maySaveDocument(document)) {
        throw new SaveVetoException();
      }
    }

    final AccessToken token =
        ApplicationManager.getApplication().acquireWriteActionLock(getClass());
    try {
      doSaveDocumentInWriteAction(document, file);
    } finally {
      token.finish();
    }
  }
示例#16
0
  private void checkForEmptyAndDuplicatedNames(
      MyNode rootNode,
      String prefix,
      String title,
      Class<? extends NamedConfigurable> configurableClass,
      boolean recursively)
      throws ConfigurationException {
    final Set<String> names = new HashSet<String>();
    for (int i = 0; i < rootNode.getChildCount(); i++) {
      final MyNode node = (MyNode) rootNode.getChildAt(i);
      final NamedConfigurable scopeConfigurable = node.getConfigurable();

      if (configurableClass.isInstance(scopeConfigurable)) {
        final String name = scopeConfigurable.getDisplayName();
        if (name.trim().length() == 0) {
          selectNodeInTree(node);
          throw new ConfigurationException("Name should contain non-space characters");
        }
        if (names.contains(name)) {
          final NamedConfigurable selectedConfigurable = getSelectedConfigurable();
          if (selectedConfigurable == null
              || !Comparing.strEqual(selectedConfigurable.getDisplayName(), name)) {
            selectNodeInTree(node);
          }
          throw new ConfigurationException(
              CommonBundle.message("smth.already.exist.error.message", prefix, name), title);
        }
        names.add(name);
      }

      if (recursively) {
        checkForEmptyAndDuplicatedNames(node, prefix, title, configurableClass, true);
      }
    }
  }
示例#17
0
    private void processOrphanModules() {
      if (myProject.isDisposed()) return;
      if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
        LOG.info(
            String.format(
                "Checking for orphan modules. External paths returned by external system: '%s'",
                myExternalModulePaths));
      }
      PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
      List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
      String externalSystemIdAsString = myExternalSystemId.toString();

      for (Module module : platformFacade.getModules(myProject)) {
        String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
        String p = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
        if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
          LOG.info(
              String.format(
                  "IDE module: EXTERNAL_SYSTEM_ID_KEY - '%s', LINKED_PROJECT_PATH_KEY - '%s'.",
                  s, p));
        }
        if (externalSystemIdAsString.equals(s) && !myExternalModulePaths.contains(p)) {
          orphanIdeModules.add(module);
          if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
            LOG.info(
                String.format(
                    "External paths doesn't contain IDE module LINKED_PROJECT_PATH_KEY anymore => add to orphan IDE modules."));
          }
        }
      }

      if (!orphanIdeModules.isEmpty()) {
        ruleOrphanModules(orphanIdeModules, myProject, myExternalSystemId);
      }
    }
 private void updateDocumentFromPropertyValue(
     final String value, final Document document, final PropertiesFile propertiesFile) {
   @NonNls String text = value;
   if (myBackSlashPressed.contains(propertiesFile)) {
     text += "\\";
   }
   document.replaceString(0, document.getTextLength(), text);
 }
  @NotNull
  public static List<SymfonyInstallerVersion> getVersions(@NotNull String jsonContent) {

    JsonObject jsonObject = new JsonParser().parse(jsonContent).getAsJsonObject();

    List<SymfonyInstallerVersion> symfonyInstallerVersions = new ArrayList<>();

    // prevent adding duplicate version on alias names
    Set<String> aliasBranches = new HashSet<>();

    // get alias version, in most common order
    for (String s : new String[] {"latest", "lts"}) {
      JsonElement asJsonObject = jsonObject.get(s);
      if (asJsonObject == null) {
        continue;
      }

      String asString = asJsonObject.getAsString();
      aliasBranches.add(asString);

      symfonyInstallerVersions.add(
          new SymfonyInstallerVersion(s, String.format("%s (%s)", asString, s)));
    }

    List<SymfonyInstallerVersion> branches = new ArrayList<>();
    Set<Map.Entry<String, JsonElement>> entries = jsonObject.entrySet();
    for (Map.Entry<String, JsonElement> entry : entries) {
      if (!entry.getKey().matches("^\\d+\\.\\d+$")) {
        continue;
      }

      // "2.8.0-dev", "2.8.0-DEV" is not supported
      String asString = entry.getValue().getAsString();
      if (asString.matches(".*[a-zA-Z].*") || aliasBranches.contains(asString)) {
        continue;
      }

      branches.add(
          new SymfonyInstallerVersion(
              asString, String.format("%s (%s)", entry.getKey(), asString)));
    }

    branches.sort(Comparator.comparing(SymfonyInstallerVersion::getVersion));

    Collections.reverse(branches);

    symfonyInstallerVersions.addAll(branches);

    // we need reverse order for sorting them on version string
    List<SymfonyInstallerVersion> installableVersions = new ArrayList<>();
    for (JsonElement installable : jsonObject.getAsJsonArray("installable")) {
      installableVersions.add(new SymfonyInstallerVersion(installable.getAsString()));
    }
    Collections.reverse(installableVersions);

    symfonyInstallerVersions.addAll(installableVersions);
    return symfonyInstallerVersions;
  }
示例#20
0
 protected void consolidateLibDir(File tomcatRoot) {
   Set<String> requiredLibs = _differ.getRequiredLibNames();
   for (String lib : _differ.getInstalledLibNames()) {
     if (lib.startsWith("h2-")) continue; // h2 db driver is also needed
     if (!requiredLibs.contains(lib)) {
       FileUtil.delete(tomcatRoot, FileUtil.buildPath("yawllib", lib));
     }
   }
 }
示例#21
0
 private void collectNotIncludedReferences(
     final RasterDataNode rasterDataNode, final Set<String> notIncludedNames) {
   final RasterDataNode[] referencedNodes = getReferencedNodes(rasterDataNode);
   for (final RasterDataNode referencedNode : referencedNodes) {
     final String name = referencedNode.getName();
     if (!productSubsetDef.isNodeAccepted(name) && !notIncludedNames.contains(name)) {
       notIncludedNames.add(name);
       collectNotIncludedReferences(referencedNode, notIncludedNames);
     }
   }
 }
  @Override
  public void saveDocument(@NotNull final Document document) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (!myUnsavedDocuments.contains(document)) return;

    try {
      doSaveDocument(document);
    } catch (IOException e) {
      handleErrorsOnSave(Collections.singletonMap(document, e));
    } catch (SaveVetoException ignored) {
    }
  }
 @Override
 public void visitReferenceExpression(final PsiReferenceExpression reference) {
   if (myLineRange.intersects(reference.getTextRange())) {
     final PsiElement psiElement = reference.resolve();
     if (psiElement instanceof PsiVariable) {
       final PsiVariable var = (PsiVariable) psiElement;
       if (var instanceof PsiField) {
         if (myCollectExpressions
             && !DebuggerUtils.hasSideEffectsOrReferencesMissingVars(
                 reference, myVisibleLocals)) {
           /*
           if (var instanceof PsiEnumConstant && reference.getQualifier() == null) {
             final PsiClass enumClass = ((PsiEnumConstant)var).getContainingClass();
             if (enumClass != null) {
               final PsiExpression expression = JavaPsiFacade.getInstance(var.getProject()).getParserFacade().createExpressionFromText(enumClass.getName() + "." + var.getName(), var);
               final PsiReference ref = expression.getReference();
               if (ref != null) {
                 ref.bindToElement(var);
                 myExpressions.add(new TextWithImportsImpl(expression));
               }
             }
           }
           else {
             myExpressions.add(new TextWithImportsImpl(reference));
           }
           */
           final PsiModifierList modifierList = var.getModifierList();
           boolean isConstant =
               (var instanceof PsiEnumConstant)
                   || (modifierList != null
                       && modifierList.hasModifierProperty(PsiModifier.STATIC)
                       && modifierList.hasModifierProperty(PsiModifier.FINAL));
           if (!isConstant) {
             myExpressions.add(new TextWithImportsImpl(reference));
           }
         }
       } else {
         if (myVisibleLocals.contains(var.getName())) {
           myVars.add(var.getName());
         } else {
           // fix for variables used in inner classes
           if (!Comparing.equal(
               PsiTreeUtil.getParentOfType(reference, PsiClass.class),
               PsiTreeUtil.getParentOfType(var, PsiClass.class))) {
             myExpressions.add(new TextWithImportsImpl(reference));
           }
         }
       }
     }
   }
   super.visitReferenceExpression(reference);
 }
 public Editor addCommitLog(String title, Editor commitLog) {
   boolean notExist = !_commitLogs.contains(commitLog);
   LOG.assertTrue(notExist);
   //noinspection ConstantConditions
   if (notExist) {
     DefaultActionGroup actions = new DefaultActionGroup();
     actions.add(new CopyContentAction(commitLog));
     addTab(
         title, commitLog.getComponent(), true, false, false, true, actions, COMMIT_LOG_HELP_ID);
     _commitLogs.add(commitLog);
   }
   return commitLog;
 }
  private void handleNotification(Project project) {
    final GerritSettings settings = GerritSettings.getInstance();

    if (!settings.getReviewNotifications()) {
      return;
    }

    String apiUrl = GerritApiUtil.getApiUrl();
    List<ChangeInfo> changes =
        GerritUtil.getChangesToReview(apiUrl, settings.getLogin(), settings.getPassword());

    boolean newChange = false;
    for (ChangeInfo change : changes) {
      if (!myNotifiedChanges.contains(change.getChangeId())) {
        newChange = true;
        break;
      }
    }
    if (newChange) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("<ul>");
      for (ChangeInfo change : changes) {
        stringBuilder
            .append("<li>")
            .append(
                !myNotifiedChanges.contains(change.getChangeId()) ? "<strong>NEW: </strong>" : "")
            .append(change.getSubject())
            .append(" (Owner: ")
            .append(change.getOwner().getName())
            .append(')')
            .append("</li>");

        myNotifiedChanges.add(change.getChangeId());
      }
      stringBuilder.append("</ul>");
      GerritUtil.notifyInformation(
          project, "Gerrit Changes waiting for my review", stringBuilder.toString());
    }
  }
示例#26
0
    // {{{ restoreSelection() method
    public void restoreSelection(Set<String> savedChecked, Set<String> savedSelection) {
      for (int i = 0, c = getRowCount(); i < c; i++) {
        Object obj = filteredEntries.get(i);
        String name = obj.toString();
        if (obj instanceof Entry) {
          name = ((Entry) obj).plugin.jar;
        }
        if (pluginSet.contains(name)) setValueAt(true, i, 0);
        else setValueAt(savedChecked.contains(name), i, 0);
      }
      if (table == null) return;

      table.setColumnSelectionInterval(0, 0);
      if (!savedSelection.isEmpty()) {
        int i = 0;
        int rowCount = getRowCount();
        for (; i < rowCount; i++) {
          String name = filteredEntries.get(i).toString();
          if (savedSelection.contains(name)) {
            table.setRowSelectionInterval(i, i);
            break;
          }
        }
        ListSelectionModel lsm = table.getSelectionModel();
        for (; i < rowCount; i++) {
          String name = filteredEntries.get(i).toString();
          if (savedSelection.contains(name)) {
            lsm.addSelectionInterval(i, i);
          }
        }
      } else {
        if (table.getRowCount() != 0) table.setRowSelectionInterval(0, 0);
        JScrollBar scrollbar = scrollpane.getVerticalScrollBar();
        scrollbar.setValue(scrollbar.getMinimum());
      }
    } // }}}
示例#27
0
  @NotNull
  public static String toKeyNotation(@NotNull KeyStroke key) {
    final char c = key.getKeyChar();
    final int keyCode = key.getKeyCode();
    final int modifiers = key.getModifiers();

    if (c != CHAR_UNDEFINED && !isControlCharacter(c)) {
      return String.valueOf(c);
    }

    String prefix = "";
    if ((modifiers & META_MASK) != 0) {
      prefix += "M-";
    }
    if ((modifiers & ALT_MASK) != 0) {
      prefix += "A-";
    }
    if ((modifiers & CTRL_MASK) != 0) {
      prefix += "C-";
    }
    if ((modifiers & SHIFT_MASK) != 0) {
      prefix += "S-";
    }

    String name = VIM_KEY_VALUES.get(keyCode);
    if (name != null) {
      if (UPPERCASE_DISPLAY_KEY_NAMES.contains(name)) {
        name = name.toUpperCase();
      } else {
        name = StringUtil.capitalize(name);
      }
    }
    if (name == null) {
      final String escape = toEscapeNotation(key);
      if (escape != null) {
        return escape;
      }

      try {
        name = String.valueOf(Character.toChars(keyCode));
      } catch (IllegalArgumentException ignored) {
      }
    }

    return name != null ? "<" + prefix + name + ">" : "<<" + key.toString() + ">>";
  }
  public void setProviders(
      List<FrameworkSupportInModuleProvider> providers,
      Set<String> associated,
      Set<String> preselected) {
    myProviders = providers;

    myAssociatedFrameworks = createNodes(myProviders, associated, preselected);
    for (FrameworkSupportNodeBase node : myRoots) {
      if (preselected.contains(node.getId())) {
        node.setChecked(true);
      }
    }
    setAssociatedFrameworks();

    myFrameworksTree.setRoots(myRoots);
    myFrameworksTree.setSelectionRow(0);
  }
示例#29
0
 @Override
 public void keyPressed(KeyEvent e) {
   // Accept "copy" key strokes
   KeyStroke ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
   JComponent comp = (JComponent) e.getSource();
   for (int i = 0; i < 3; i++) {
     InputMap im = comp.getInputMap(i);
     Object key = im.get(ks);
     if (defaultEditorKitCopyActionName.equals(key)
         || transferHandlerCopyActionName.equals(key)) {
       return;
     }
   }
   // Accept JTable navigation key strokes
   if (!tableNavigationKeys.contains(e.getKeyCode())) {
     e.consume();
   }
 }
 private boolean checkBeforeRunTasksAbility(boolean checkOnlyAddAction) {
   if (isUnknown()) {
     return false;
   }
   Set<Key> activeProviderKeys = getActiveProviderKeys();
   final BeforeRunTaskProvider<BeforeRunTask>[] providers =
       Extensions.getExtensions(
           BeforeRunTaskProvider.EXTENSION_POINT_NAME, myRunConfiguration.getProject());
   for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
     if (provider.createTask(myRunConfiguration) != null) {
       if (!checkOnlyAddAction) {
         return true;
       } else if (!provider.isSingleton() || !activeProviderKeys.contains(provider.getId())) {
         return true;
       }
     }
   }
   return false;
 }