本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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;
}
示例15: getPresentableText
import com.intellij.psi.PsiNamedElement; //导入方法依赖的package包/类
@Override
public String getPresentableText() {
final PsiNamedElement namedElement = getElement();
return namedElement != null ? namedElement.getName():"";
}