當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiNamedElement.getName方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiNamedElement.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiNamedElement.getName方法的具體用法?Java PsiNamedElement.getName怎麽用?Java PsiNamedElement.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiNamedElement的用法示例。


在下文中一共展示了PsiNamedElement.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: suggestAllNames

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
protected void suggestAllNames(final String oldClassName, String newClassName) {
  final NameSuggester suggester = new NameSuggester(oldClassName, newClassName);
  for (int varIndex = myElements.size() - 1; varIndex >= 0; varIndex--) {
    final PsiNamedElement element = myElements.get(varIndex);
    final String name = element.getName();
    if (!myRenames.containsKey(element) && name != null) {
      String newName = suggestNameForElement(element, suggester, newClassName, oldClassName);
      if (!newName.equals(name)) {
        myRenames.put(element, newName);
      }
      else {
        myRenames.put(element, null);
      }
    }
    if (myRenames.get(element) == null) {
      myElements.remove(varIndex);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:AutomaticRenamer.java

示例2: process

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
public boolean process(BuildElement buildElement) {
  if (buildElement == originalElement) {
    return true;
  }
  if (buildElement instanceof LoadedSymbol) {
    LoadedSymbol loadedSymbol = (LoadedSymbol) buildElement;
    String string = loadedSymbol.getSymbolString();
    results.put(string, new LoadedSymbolReferenceLookupElement(loadedSymbol, string, quoteType));
  } else if (buildElement instanceof PsiNamedElement) {
    PsiNamedElement namedElement = (PsiNamedElement) buildElement;
    String name = namedElement.getName();
    if (!allowPrivateSymbols && name != null && name.startsWith("_")) {
      return true;
    }
    results.put(name, new NamedBuildLookupElement((PsiNamedElement) buildElement, quoteType));
  }
  return true;
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:20,代碼來源:CompletionResultsProcessor.java

示例3: getName

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Nullable
public static String getName(@NotNull PsiNamedElement element, boolean qualified) {
  if (element instanceof SchemaQnSegment) {
    SchemaQnSegment qnSegment = (SchemaQnSegment) element;
    return qnSegment.getQn().toString();
  }

  String shortName = element.getName();
  if (shortName == null) return null;

  if (qualified) {
    Qn namespace;
    if (element instanceof SchemaTypeDef) {
      SchemaTypeDef typeDef = (SchemaTypeDef) element;
      namespace = typeDef.getNamespace();
    } else namespace = NamespaceManager.getNamespace(element);
    return namespace == null ? shortName : namespace.append(shortName).toString();
  } else return shortName;
}
 
開發者ID:SumoLogic,項目名稱:epigraph,代碼行數:20,代碼來源:SchemaPresentationUtil.java

示例4: findFeatureName

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
private String findFeatureName( FeaturePath path )
{
  PsiClass root = path.getRoot();
  String fqn = root.getQualifiedName();
  PsiClass psiClass = JavaPsiFacade.getInstance( root.getProject() ).findClass( fqn, GlobalSearchScope.moduleScope( ModuleUtilCore.findModuleForPsiElement( root ) ) );
  if( psiClass == null )
  {
    return null;
  }
  PsiNamedElement renamedFeature = findFeatureElement( psiClass, path.getChild() );
  return renamedFeature == null ? null : renamedFeature.getName();
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:13,代碼來源:RenameResourceElementProcessor.java

示例5: getQualifiedFullName

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
public static String getQualifiedFullName(SmcAction action) {
    PsiNamedElement transition = PsiTreeUtil.getParentOfType(action, SmcTransition.class);
    String actionParentName;
    if (transition != null) {
        actionParentName = transition.getName();
    } else {
        SmcOnStateNestedElement onState = PsiTreeUtil.getParentOfType(action, SmcOnStateNestedElement.class);
        actionParentName = onState != null ? onState.getType() : "";
    }

    SmcState state = PsiTreeUtil.getParentOfType(action, SmcState.class);
    return (state != null ? state.getName() + STRING_DOT : "") + actionParentName + STRING_DOT + action.getFullName();
}
 
開發者ID:menshele,項目名稱:smcplugin,代碼行數:14,代碼來源:SmcPsiImplUtil.java

示例6: getNextNamedParent

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
private PsiNamedElement getNextNamedParent(final PsiElement psiElement) {
    if (psiElement == null) {
        return null;
    }

    if (psiElement instanceof PsiNamedElement) {
        final PsiNamedElement namedElement = (PsiNamedElement) psiElement;

        if (namedElement.getName() != null && !namedElement.getName().contains(DUMMY_IDENTIFIER)) {
            return namedElement;
        }
    }

    return getNextNamedParent(psiElement.getParent());
}
 
開發者ID:zalando,項目名稱:intellij-swagger,代碼行數:16,代碼來源:PathFinder.java

示例7: getNameForElement

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
/**
 * Returns presentation name for given element.
 */
@Nullable
public static String getNameForElement(PsiElement element) {
    if (element instanceof DataType) {
        DataType type = (DataType) element;
        return type.getFullName();
    }
    if (element instanceof ProtoRootNode) {
        ProtoRootNode rootNode = (ProtoRootNode) element;
        String packageName = rootNode.getPackageName();
        if (packageName.isEmpty()) {
            return null;
        }
        return packageName;
    }
    if (element instanceof MessageField) {
        MessageField field = (MessageField) element;
        String fieldName = field.getFieldName();
        DataTypeContainer container = PsiTreeUtil.getParentOfType(element, DataTypeContainer.class);
        String conteinerName = getNameForElement(container);
        if (conteinerName != null) {
            return ProtostuffBundle.message("element.context.display", fieldName, conteinerName);
        } else {
            return fieldName;
        }
    }
    if (element instanceof PsiNamedElement) {
        PsiNamedElement namedElement = (PsiNamedElement) element;
        return namedElement.getName();
    }
    return null;
}
 
開發者ID:protostuff,項目名稱:protobuf-jetbrains-plugin,代碼行數:35,代碼來源:PresentationUtil.java

示例8: execute

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
  if (element instanceof PsiNamedElement && element.isValid()) {
    PsiNamedElement named = (PsiNamedElement)element;
    String name = named.getName();
    if (name != null) {
      PsiAnchor context = myCurrentContextAnchor;
      if (context == null && myCurrentFileContext != null) {
        myCurrentContextAnchor = context = PsiAnchor.create(myCurrentFileContext);
      }
      myResult.add(name, new ResultWithContext(named, context));
    }
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:SymbolCollectingProcessor.java

示例9: perform

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
protected void perform() {
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
  assertTrue(element instanceof PsiNamedElement);

  final PsiNamedElement namedElement = (PsiNamedElement)element;
  final String name = namedElement.getName();
  new InvertBooleanProcessor(namedElement, name + "Inverted").run();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:InvertBooleanTest.java

示例10: suggestNameForElement

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
protected String suggestNameForElement(PsiNamedElement element, NameSuggester suggester, String newClassName, String oldClassName) {
  String name = element.getName();
  if (oldClassName.equals(name)) {
    return newClassName;
  }
  String canonicalName = nameToCanonicalName(name, element);
  final String newCanonicalName = suggester.suggestName(canonicalName);
  if (newCanonicalName.length() == 0) {
    LOG.error("oldClassName = " + oldClassName + ", newClassName = " + newClassName + ", name = " + name + ", canonicalName = " +
              canonicalName + ", newCanonicalName = " + newCanonicalName);
  }
  return canonicalNameToName(newCanonicalName, element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:AutomaticRenamer.java

示例11: doTest

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
private void doTest(List<String> files) {
  files.add(0, "refactoring/invertBoolean/" + getTestName(true) + ".before.py");
  myFixture.configureByFiles(files.toArray(new String[files.size()]));
  final PsiElement element = myFixture.getElementAtCaret();
  assertTrue(element instanceof PsiNamedElement);

  final PsiNamedElement target = (PsiNamedElement)element;
  final String name = target.getName();
  assertNotNull(name);
  new InvertBooleanProcessor(target, "not" + StringUtil.toTitleCase(name)).run();
  myFixture.checkResultByFile("refactoring/invertBoolean/" + getTestName(true) + ".after.py");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:PyInvertBooleanTest.java

示例12: buildErrorString

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
@NotNull
public String buildErrorString(Object... arg) {
  final PsiNamedElement variable = (PsiNamedElement)arg[0];
  final String name = variable.getName();
  return InspectionGadgetsBundle.message(
    "local.variable.of.concrete.class.problem.descriptor", name);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:LocalVariableOfConcreteClassInspection.java

示例13: buildErrorString

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
@NotNull
public String buildErrorString(Object... infos) {
  final PsiNamedElement element = (PsiNamedElement)infos[0];
  final String className = element.getName();
  return InspectionGadgetsBundle.message("feature.envy.problem.descriptor", className);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:FeatureEnvyInspectionBase.java

示例14: getItemName

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Nullable
@Override
public SimpleColoredText getItemName(Object o, DiagramState diagramState) {
  if (o instanceof PsiNamedElement) {
    PsiNamedElement namedElement = (PsiNamedElement) o;

    final String itemName, itemType;

    if (namedElement instanceof SchemaFieldDecl) {
      SchemaFieldDecl fieldDecl = (SchemaFieldDecl) namedElement;

      itemName = fieldDecl.getQid().getCanonicalName();
      SchemaValueTypeRef valueTypeRef = fieldDecl.getValueTypeRef();

      itemType = valueTypeRef == null ? null : valueTypeRef.getTypeRef().getText();
    } else if (namedElement instanceof SchemaEntityTagDecl) {
      SchemaEntityTagDecl tagDecl = (SchemaEntityTagDecl) namedElement;

      itemName = tagDecl.getQid().getCanonicalName();
      SchemaTypeRef typeRef = tagDecl.getTypeRef();

      itemType = typeRef == null ? null : typeRef.getText();
    } else {
      itemName = namedElement.getName();
      if (itemName == null) return null;

      itemType = null;
    }

    SimpleColoredText res = new SimpleColoredText(itemName, DEFAULT_TITLE_ATTR);
    if (itemType != null) res.append(" : " + itemType, DEFAULT_TEXT_ATTR);

    return res;
  }

  return null;
}
 
開發者ID:SumoLogic,項目名稱:epigraph,代碼行數:38,代碼來源:SchemaDiagramElementManager.java

示例15: getPresentableText

import com.intellij.psi.PsiNamedElement; //導入方法依賴的package包/類
@Override
public String getPresentableText() {
  final PsiNamedElement namedElement = getElement();
  return namedElement != null ? namedElement.getName():"";
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:6,代碼來源:DtdFileTreeElement.java


注:本文中的com.intellij.psi.PsiNamedElement.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。