当前位置: 首页>>代码示例>>Java>>正文


Java MethodParameterInjection类代码示例

本文整理汇总了Java中org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection的典型用法代码示例。如果您正苦于以下问题:Java MethodParameterInjection类的具体用法?Java MethodParameterInjection怎么用?Java MethodParameterInjection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodParameterInjection类属于org.intellij.plugins.intelliLang.inject.config包,在下文中一共展示了MethodParameterInjection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: editInjectionInPlace

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
public boolean editInjectionInPlace(final PsiLanguageInjectionHost psiElement) {
  if (!isMine(psiElement)) return false;
  final HashMap<BaseInjection, Pair<PsiMethod, Integer>> injectionsMap = new HashMap<BaseInjection, Pair<PsiMethod, Integer>>();
  final ArrayList<PsiElement> annotations = new ArrayList<PsiElement>();
  final PsiLiteralExpression host = (PsiLiteralExpression)psiElement;
  final Project project = host.getProject();
  final Configuration configuration = Configuration.getProjectInstance(project);
  collectInjections(host, configuration, this, injectionsMap, annotations);
  if (injectionsMap.isEmpty() || !annotations.isEmpty()) return false;

  final BaseInjection originalInjection = injectionsMap.keySet().iterator().next();
  final MethodParameterInjection methodParameterInjection = createFrom(psiElement.getProject(), originalInjection,
                                                                       injectionsMap.get(originalInjection).first, false);
  final MethodParameterInjection copy = methodParameterInjection.copy();
  final BaseInjection newInjection = showInjectionUI(project, methodParameterInjection);
  if (newInjection != null) {
    newInjection.mergeOriginalPlacesFrom(copy, false);
    newInjection.mergeOriginalPlacesFrom(originalInjection, true);
    configuration.replaceInjectionsWithUndo(
      project, Collections.singletonList(newInjection), Collections.singletonList(originalInjection), Collections.<PsiAnnotation>emptyList());
  }
  return true;

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaLanguageInjectionSupport.java

示例2: showInjectionUI

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
  final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
  panel.reset();
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter");
  builder.addOkAction();
  builder.addCancelAction();
  builder.setCenterPanel(panel.getComponent());
  builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
  builder.setOkOperation(new Runnable() {
    public void run() {
      panel.apply();
      builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
    }
  });
  if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
    return new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaLanguageInjectionSupport.java

示例3: doEditInjection

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private static void doEditInjection(final Project project, final MethodParameterInjection template, final PsiMethod contextMethod) {
  final Configuration configuration = InjectorUtils.getEditableInstance(project);
  final BaseInjection baseTemplate = new BaseInjection(template.getSupportId()).copyFrom(template);
  final MethodParameterInjection allMethodParameterInjection = createFrom(project, baseTemplate, contextMethod, true);
  // find existing injection for this class.
  final BaseInjection originalInjection = configuration.findExistingInjection(allMethodParameterInjection);
  final MethodParameterInjection methodParameterInjection;
  if (originalInjection == null) {
    methodParameterInjection = template;
  }
  else {
    final BaseInjection originalCopy = originalInjection.copy();
    final InjectionPlace currentPlace = template.getInjectionPlaces()[0];
    originalCopy.mergeOriginalPlacesFrom(template, true);
    originalCopy.setPlaceEnabled(currentPlace.getText(), true);
    methodParameterInjection = createFrom(project, originalCopy, contextMethod, false);
  }
  mergePlacesAndAddToConfiguration(project, configuration, methodParameterInjection, originalInjection);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaLanguageInjectionSupport.java

示例4: createEditAction

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
@Override
public AnAction createEditAction(final Project project, final Factory<BaseInjection> producer) {
  return new AnAction() {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      final BaseInjection originalInjection = producer.create();
      final MethodParameterInjection injection = createFrom(project, originalInjection, null, false);
      if (injection != null) {
        final boolean mergeEnabled = !project.isInitialized() || 
          JavaPsiFacade.getInstance(project).findClass(injection.getClassName(), GlobalSearchScope.allScope(project)) == null;
        final BaseInjection newInjection = showInjectionUI(project, injection);
        if (newInjection != null) {
          newInjection.mergeOriginalPlacesFrom(originalInjection, mergeEnabled);
          originalInjection.copyFrom(newInjection);
        }
      }
      else {
        createDefaultEditAction(project, producer).actionPerformed(null);
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaLanguageInjectionSupport.java

示例5: editInjectionInPlace

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
public boolean editInjectionInPlace(final PsiLanguageInjectionHost psiElement) {
  if (!isMine(psiElement)) return false;
  final HashMap<BaseInjection, Pair<PsiMethod, Integer>> injectionsMap = new HashMap<BaseInjection, Pair<PsiMethod, Integer>>();
  final ArrayList<PsiElement> annotations = new ArrayList<PsiElement>();
  final PsiLiteralExpression host = (PsiLiteralExpression)psiElement;
  final Project project = host.getProject();
  final Configuration configuration = Configuration.getProjectInstance(project);
  collectInjections(host, configuration, this, injectionsMap, annotations);
  if (injectionsMap.isEmpty() || !annotations.isEmpty()) return false;

  final BaseInjection originalInjection = injectionsMap.keySet().iterator().next();
  final MethodParameterInjection methodParameterInjection = createFrom(psiElement.getProject(), originalInjection, injectionsMap.get(originalInjection).first, false);
  final MethodParameterInjection copy = methodParameterInjection.copy();
  final BaseInjection newInjection = showInjectionUI(project, methodParameterInjection);
  if (newInjection != null) {
    newInjection.mergeOriginalPlacesFrom(copy, false);
    newInjection.mergeOriginalPlacesFrom(originalInjection, true);
    configuration.replaceInjectionsWithUndo(
      project, Collections.singletonList(newInjection), Collections.singletonList(originalInjection), Collections.<PsiAnnotation>emptyList());
  }
  return true;

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:JavaLanguageInjectionSupport.java

示例6: createEditAction

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
@Override
public AnAction createEditAction(final Project project, final Factory<BaseInjection> producer) {
  return new AnAction() {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      final BaseInjection originalInjection = producer.create();
      final MethodParameterInjection injection = createFrom(project, originalInjection, null, false);
      if (injection != null) {
        final boolean mergeEnabled = !project.isInitialized() ||
                                     JavaPsiFacade.getInstance(project).findClass(injection.getClassName(), GlobalSearchScope.allScope(project)) == null;
        final BaseInjection newInjection = showInjectionUI(project, injection);
        if (newInjection != null) {
          newInjection.mergeOriginalPlacesFrom(originalInjection, mergeEnabled);
          originalInjection.copyFrom(newInjection);
        }
      }
      else {
        createDefaultEditAction(project, producer).actionPerformed(null);
      }
    }
  };
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:JavaLanguageInjectionSupport.java

示例7: mergePlacesAndAddToConfiguration

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private static void mergePlacesAndAddToConfiguration(@NotNull Project project,
                                                     @NotNull Configuration configuration,
                                                     @NotNull MethodParameterInjection injection,
                                                     @Nullable BaseInjection originalInjection) {
  BaseInjection newInjection = new BaseInjection(injection.getSupportId()).copyFrom(injection);
  if (originalInjection != null) {
    newInjection.mergeOriginalPlacesFrom(originalInjection, true);
  }
  configuration.replaceInjectionsWithUndo(
    project, Collections.singletonList(newInjection),
    ContainerUtil.createMaybeSingletonList(originalInjection),
    Collections.<PsiElement>emptyList());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaLanguageInjectionSupport.java

示例8: createAddActions

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
@Override
public AnAction[] createAddActions(final Project project, final Consumer<BaseInjection> consumer) {
  return new AnAction[] {
    new AnAction("Java Parameter", null, PlatformIcons.PARAMETER_ICON) {
      @Override
      public void actionPerformed(final AnActionEvent e) {
        final BaseInjection injection = showInjectionUI(project, new MethodParameterInjection());
        if (injection != null) consumer.consume(injection);
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaLanguageInjectionSupport.java

示例9: rebuildTreeModel

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private void rebuildTreeModel() {
  myData.clear();
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      final PsiType classType = getClassType();
      final PsiClass[] classes = classType instanceof PsiClassType? JavaPsiFacade.getInstance(myProject).
        findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(myProject)) : PsiClass.EMPTY_ARRAY;
      if (classes.length == 0) return;
      final THashSet<String> visitedSignatures = new THashSet<String>();
      for (PsiClass psiClass : classes) {
        for (PsiMethod method : psiClass.getMethods()) {
          final PsiModifierList modifiers = method.getModifierList();
          if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) || modifiers.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) continue;
          if (MethodParameterInjection.isInjectable(method.getReturnType(), method.getProject()) ||
              ContainerUtil.find(method.getParameterList().getParameters(), new Condition<PsiParameter>() {
                public boolean value(PsiParameter p) {
                  return MethodParameterInjection.isInjectable(p.getType(), p.getProject());
                }
              }) != null) {
            final MethodParameterInjection.MethodInfo info = MethodParameterInjection.createMethodInfo(method);
            if (!visitedSignatures.add(info.getMethodSignature())) continue;
            myData.put(method, info);
          }
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MethodParameterPanel.java

示例10: apply

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
protected void apply(final MethodParameterInjection other) {
  final boolean applyMethods = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    public Boolean compute() {
      other.setClassName(getClassName());
      return getClassType() != null;
    }
  }).booleanValue();
  if (applyMethods) {
    other.setMethodInfos(ContainerUtil.findAll(myData.values(), new Condition<MethodParameterInjection.MethodInfo>() {
      public boolean value(final MethodParameterInjection.MethodInfo methodInfo) {
        return methodInfo.isEnabled();
      }
    }));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:MethodParameterPanel.java

示例11: doEditInjection

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private static void doEditInjection(final Project project, final MethodParameterInjection template, final PsiMethod contextMethod) {
  final Configuration configuration = InjectorUtils.getEditableInstance(project);
  final BaseInjection baseTemplate = new BaseInjection(template.getSupportId()).copyFrom(template);
  final MethodParameterInjection allMethodParameterInjection = createFrom(project, baseTemplate, contextMethod, true);
  // find existing injection for this class.
  final BaseInjection originalInjection = configuration.findExistingInjection(allMethodParameterInjection);
  final MethodParameterInjection methodParameterInjection;
  if (originalInjection == null) {
    methodParameterInjection = template;
  }
  else {
    final BaseInjection originalCopy = originalInjection.copy();
    final InjectionPlace currentPlace = template.getInjectionPlaces()[0];
    originalCopy.mergeOriginalPlacesFrom(template, true);
    originalCopy.setPlaceEnabled(currentPlace.getText(), true);
    methodParameterInjection = createFrom(project, originalCopy, contextMethod, false);
  }
  if (InjectLanguageAction.doEditConfigurable(project, new MethodParameterInjectionConfigurable(methodParameterInjection, null, project))) {
    final BaseInjection newInjection = new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection);
    if (originalInjection != null) {
      newInjection.mergeOriginalPlacesFrom(originalInjection, true);
    }
    configuration.replaceInjectionsWithUndo(
      project, Collections.singletonList(newInjection),
      ContainerUtil.createMaybeSingletonList(originalInjection),
      Collections.<PsiElement>emptyList());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:JavaLanguageInjectionSupport.java

示例12: rebuildTreeModel

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
private void rebuildTreeModel() {
  myData.clear();
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      final PsiType classType = getClassType();
      final PsiClass[] classes = classType instanceof PsiClassType? JavaPsiFacade.getInstance(getProject()).
        findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(getProject())) : PsiClass.EMPTY_ARRAY;
      if (classes.length == 0) return;
      final THashSet<String> visitedSignatures = new THashSet<String>();
      for (PsiClass psiClass : classes) {
        for (PsiMethod method : psiClass.getMethods()) {
          final PsiModifierList modifiers = method.getModifierList();
          if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) || modifiers.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) continue;
          if (MethodParameterInjection.isInjectable(method.getReturnType(), method.getProject()) ||
              ContainerUtil.find(method.getParameterList().getParameters(), new Condition<PsiParameter>() {
                public boolean value(PsiParameter p) {
                  return MethodParameterInjection.isInjectable(p.getType(), p.getProject());
                }
              }) != null) {
            final MethodParameterInjection.MethodInfo info = MethodParameterInjection.createMethodInfo(method);
            if (!visitedSignatures.add(info.getMethodSignature())) continue;
            myData.put(method, info);
          }
        }
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:29,代码来源:MethodParameterPanel.java

示例13: getPatternStringForJavaPlace

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
public static String getPatternStringForJavaPlace(final PsiMethod method, final int parameterIndex) {
  final PsiClass psiClass = method.getContainingClass();
  final String className = psiClass == null ? "" : StringUtil.notNullize(psiClass.getQualifiedName());
  final String signature = createMethodInfo(method).getMethodSignature();
  return MethodParameterInjection.getPatternStringForJavaPlace(method.getName(), getParameterTypesString(signature), parameterIndex, className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:JavaLanguageInjectionSupport.java

示例14: createInjection

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
public BaseInjection createInjection(final Element element) {
  if (element.getName().equals(MethodParameterInjection.class.getSimpleName())) {
    return new MethodParameterInjection();
  }
  else return new BaseInjection(JAVA_SUPPORT_ID);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:JavaLanguageInjectionSupport.java

示例15: MethodParameterInjectionConfigurable

import org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection; //导入依赖的package包/类
public MethodParameterInjectionConfigurable(MethodParameterInjection injection, Runnable treeUpdater, Project project) {
  super(injection, treeUpdater, project);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:MethodParameterInjectionConfigurable.java


注:本文中的org.intellij.plugins.intelliLang.inject.config.MethodParameterInjection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。