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


Java PsiVariable.getName方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiVariable.getName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiVariable.getName方法的具体用法?Java PsiVariable.getName怎么用?Java PsiVariable.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiVariable的用法示例。


在下文中一共展示了PsiVariable.getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(PsiVariable variable) {
  super.visitVariable(variable);
  if (!PsiType.BOOLEAN.equals(variable.getType())) {
    return;
  }
  final String name = variable.getName();
  final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(variable.getProject());
  final String prefix = codeStyleManager.getPrefixByVariableKind(codeStyleManager.getVariableKind(variable));
  for (final String negativeName : NEGATIVE_NAMES) {
    if (isNegativelyNamed(name, negativeName) || !prefix.isEmpty() && isNegativelyNamed(name, prefix + negativeName)) {
      registerVariableError(variable, variable);
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NegativelyNamedBooleanVariableInspectionBase.java

示例2: validateSingular

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
private boolean validateSingular(@NotNull PsiClass psiClass, @NotNull ProblemBuilder problemBuilder) {
  boolean result = true;

  final AccessorsInfo accessorsInfo = AccessorsInfo.build(psiClass);
  final Collection<PsiField> builderFields = getBuilderFields(psiClass, Collections.<PsiField>emptySet(), accessorsInfo);
  for (PsiVariable builderVariable : builderFields) {
    final PsiAnnotation singularAnnotation = PsiAnnotationSearchUtil.findAnnotation(builderVariable, Singular.class);
    if (null != singularAnnotation) {
      final String qualifiedName = PsiTypeUtil.getQualifiedName(builderVariable.getType());
      if (SingularHandlerFactory.isInvalidSingularType(qualifiedName)) {
        problemBuilder.addError("Lombok does not know how to create the singular-form builder methods for type '%s'; " +
          "they won't be generated.", qualifiedName != null ? qualifiedName : builderVariable.getType().getCanonicalText());
        result = false;
      }

      final String variableName = builderVariable.getName();
      if (!AbstractSingularHandler.validateSingularName(singularAnnotation, accessorsInfo.removePrefix(variableName))) {
        problemBuilder.addError("Can't singularize this name: \"%s\"; please specify the singular explicitly (i.e. @Singular(\"sheep\"))", variableName);
        result = false;
      }
    }
  }
  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:BuilderHandler.java

示例3: execute

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
/** Always return true since we wanna get all vars in scope */
@Override
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state){
  if(pe instanceof PsiVariable){
    final PsiVariable pvar = (PsiVariable)pe;
    final String pvar_name = pvar.getName();
    if(pvar_name.startsWith(myPrefix)){
      if(!myStaticSensitiveFlag || (!myStaticScopeFlag || pvar.hasModifierProperty(PsiModifier.STATIC))){
        myResultList.add(pvar);
      }
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:VariablesProcessor.java

示例4: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
  final String name = variable.getName();
  if (nameSet.contains(name)) {
    registerVariableError(variable);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:QuestionableNameInspectionBase.java

示例5: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
  super.visitVariable(variable);
  final String name = variable.getName();
  if (name == null) {
    return;
  }
  if (name.indexOf((int)'$') < 0) {
    return;
  }
  registerVariableError(variable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DollarSignInNameInspectionBase.java

示例6: execute

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
/** Always return true since we wanna get all vars in scope */
@Override
public boolean execute(@NotNull PsiElement pe, ResolveState state){
  if(pe instanceof PsiVariable){
    final PsiVariable pvar = (PsiVariable)pe;
    final String pvar_name = pvar.getName();
    if(pvar_name.startsWith(myPrefix)){
      if(!myStaticSensitiveFlag || (!myStaticScopeFlag || pvar.hasModifierProperty(PsiModifier.STATIC))){
        myResultList.add(pvar);
      }
    }
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:VariablesProcessor.java

示例7: prepareRenaming

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames) {
  final PsiClass topLevelClass = PsiUtil.getTopLevelClass(element);
  if (topLevelClass == null) {
    return;
  }

  final PsiVariable psiVariable = (PsiVariable) element;
  final String oldName = psiVariable.getName();

  final BeanBindingMetaData dataBindingMetaData = DataBindUtil.getDataBindingMetaData(topLevelClass);
  if (dataBindingMetaData == null) {
    return;
  }
  final Map<String, PropertyInfo> allProperties
      = DataBindUtil.getAllProperties(dataBindingMetaData.getBoundClass(), "");

  final PropertyInfo propertyInfo = allProperties.get(oldName);
  if (propertyInfo == null) {
    return;
  }

  final PsiField associatedField = propertyInfo.getAssociatedField();
  if (associatedField == null) {
    return;
  }

  super.prepareRenaming(associatedField, newName, allRenames);
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:30,代码来源:BoundFieldRenameProcessor.java

示例8: prepareRenaming

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames) {
  final PsiClass topLevelClass = PsiUtil.getTopLevelClass(element);
  if (topLevelClass == null) {
    return;
  }

  final PsiVariable psiVariable = (PsiVariable) element;
  final String oldName = psiVariable.getName();

  final TemplateMetaData templateMetaData = TemplateUtil.getTemplateMetaData(topLevelClass);

  final Multimap<String, TemplateDataField> dataFields = templateMetaData.getAllDataFieldsInTemplate(false);
  final Collection<TemplateDataField> dataField = dataFields.get(oldName);

  if (dataField.size() != 1) {
    return;
  }

  final XmlAttribute dataFieldAttribute = dataField.iterator().next().getDataFieldAttribute();
  if (dataFieldAttribute != null && dataFieldAttribute.getValueElement() != null) {
    FakeNamedPsi fakeNamedPsi = new FakeNamedPsi(dataFieldAttribute) {
      @Override
      public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
        dataFieldAttribute.setValue(name);
        return dataFieldAttribute;
      }

      @Override
      public String getName() {
        return dataFieldAttribute.getValue();
      }
    };

    allRenames.put(fakeNamedPsi, newName);
  }
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:38,代码来源:BeanDataFieldRenameProcessor.java

示例9: computeJavaLangBooleanFieldReference

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Nullable
private static Boolean computeJavaLangBooleanFieldReference(final PsiVariable variable)
{
	if(!(variable instanceof PsiField))
	{
		return null;
	}
	PsiClass psiClass = ((PsiField) variable).getContainingClass();
	if(psiClass == null || !CommonClassNames.JAVA_LANG_BOOLEAN.equals(psiClass.getQualifiedName()))
	{
		return null;
	}
	@NonNls String name = variable.getName();
	return "TRUE".equals(name) ? Boolean.TRUE : "FALSE".equals(name) ? Boolean.FALSE : null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:DfaConstValue.java

示例10: check

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
protected boolean check(PsiVariable var, ResolveState state) {
  String name = var.getName();
  return name != null && name.equals(myVariable.getName()) && !var.equals(myVariable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:VariablesNotProcessor.java

示例11: VariableSubLookupElement

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
public VariableSubLookupElement(final PsiVariable variable) {
  myVarName = variable.getName();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:VariableSubLookupElement.java

示例12: VariableTypeFix

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
public VariableTypeFix(@NotNull PsiVariable variable, PsiType toReturn)
{
	super(variable);
	myReturnType = GenericsUtil.getVariableTypeByExpressionType(toReturn);
	myName = variable.getName();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:VariableTypeFix.java


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