Java Code Examples for com.intellij.lang.java.JavaLanguage#INSTANCE

The following examples show how to use com.intellij.lang.java.JavaLanguage#INSTANCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqliteMagicLightMethodBuilder.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
public SqliteMagicLightMethodBuilder(@NotNull PsiManager manager, @NotNull String name) {
  super(manager, JavaLanguage.INSTANCE, name,
      new SqliteMagicLightParameterListBuilder(manager, JavaLanguage.INSTANCE),
      new SqliteMagicLightModifierList(manager, JavaLanguage.INSTANCE));
  myThrowsList = new SqliteMagicLightReferenceListBuilder(manager, JavaLanguage.INSTANCE, PsiReferenceList.Role.THROWS_LIST);
  setBaseIcon(SqliteMagicIcons.METHOD_ICON);
}
 
Example 2
Source File: WitherFieldProcessor.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
public PsiMethod createWitherMethod(@NotNull PsiField psiField, @NotNull String methodModifier, @NotNull AccessorsInfo accessorsInfo) {
  LombokLightMethodBuilder methodBuilder = null;
  final PsiClass psiFieldContainingClass = psiField.getContainingClass();
  if (psiFieldContainingClass != null) {
    final PsiType returnType = PsiClassUtil.getTypeWithGenerics(psiFieldContainingClass);
    final String psiFieldName = psiField.getName();
    final PsiType psiFieldType = psiField.getType();

    methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), getWitherName(accessorsInfo, psiFieldName, psiFieldType))
      .withMethodReturnType(returnType)
      .withContainingClass(psiFieldContainingClass)
      .withNavigationElement(psiField)
      .withModifier(methodModifier);

    PsiAnnotation witherAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, Wither.class, With.class);
    addOnXAnnotations(witherAnnotation, methodBuilder.getModifierList(), "onMethod");

    final LombokLightParameter methodParameter = new LombokLightParameter(psiFieldName, psiFieldType, methodBuilder, JavaLanguage.INSTANCE);
    PsiModifierList methodParameterModifierList = methodParameter.getModifierList();
    copyAnnotations(psiField, methodParameterModifierList,
      LombokUtils.NON_NULL_PATTERN, LombokUtils.NULLABLE_PATTERN, LombokUtils.DEPRECATED_PATTERN);
    addOnXAnnotations(witherAnnotation, methodParameterModifierList, "onParam");
    methodBuilder.withParameter(methodParameter);

    if (psiFieldContainingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
      methodBuilder.withModifier(PsiModifier.ABSTRACT);
    } else {
      final String paramString = getConstructorCall(psiField, psiFieldContainingClass);
      final String blockText = String.format("return this.%s == %s ? this : new %s(%s);", psiFieldName, psiFieldName, returnType.getCanonicalText(), paramString);
      methodBuilder.withBody(PsiMethodUtil.createCodeBlockFromText(blockText, methodBuilder));
    }
  }
  return methodBuilder;
}
 
Example 3
Source File: LombokLightFieldBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public LombokLightFieldBuilder(@NotNull PsiManager manager, @NotNull String name, @NotNull PsiType type) {
  super(manager, name, type);
  myName = name;
  myNameIdentifier = new LombokLightIdentifier(manager, name);
  myModifierList = new LombokLightModifierList(manager, JavaLanguage.INSTANCE, Collections.emptyList());
  setBaseIcon(LombokIcons.FIELD_ICON);
}
 
Example 4
Source File: LombokLightMethodBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public LombokLightMethodBuilder(@NotNull PsiManager manager, @NotNull String name) {
  super(manager, JavaLanguage.INSTANCE, name,
    new LombokLightParameterListBuilder(manager, JavaLanguage.INSTANCE),
    new LombokLightModifierList(manager, JavaLanguage.INSTANCE, Collections.emptySet()),
    new LombokLightReferenceListBuilder(manager, JavaLanguage.INSTANCE, PsiReferenceList.Role.THROWS_LIST),
    new LightTypeParameterListBuilder(manager, JavaLanguage.INSTANCE));
  setBaseIcon(LombokIcons.METHOD_ICON);
}
 
Example 5
Source File: LombokLightMethodBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private LombokLightParameter createParameter(@NotNull String name, @NotNull PsiType type) {
  return new LombokLightParameter(name, type, this, JavaLanguage.INSTANCE);
}
 
Example 6
Source File: LombokInlineMethodHandler.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public boolean canInlineElement(PsiElement element) {
  return element instanceof LombokLightMethodBuilder && element.getLanguage() == JavaLanguage.INSTANCE;
}