本文整理汇总了Java中com.jetbrains.php.PhpIndex.getBySignature方法的典型用法代码示例。如果您正苦于以下问题:Java PhpIndex.getBySignature方法的具体用法?Java PhpIndex.getBySignature怎么用?Java PhpIndex.getBySignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.PhpIndex
的用法示例。
在下文中一共展示了PhpIndex.getBySignature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertPhpReferenceSignatureEquals
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
protected void assertPhpReferenceSignatureEquals(LanguageFileType languageFileType, @NotNull Class aClass, String configureByText, String typeSignature) {
myFixture.configureByText(languageFileType, configureByText);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
psiElement = PsiTreeUtil.getParentOfType(psiElement, aClass);
if (!(psiElement instanceof PhpReference)) {
fail("Element is not PhpReference.");
}
PhpIndex phpIndex = PhpIndex.getInstance(myFixture.getProject());
Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(((PhpReference)psiElement).getSignature(), null, 0);
assertNotEmpty(collection);
for (String type : collection.iterator().next().getType().getTypes()) {
if (type.equals(typeSignature)) {
return;
}
}
fail("Can't find type: "+typeSignature+", found:"+collection.iterator().next().getType().toString());
}
示例2: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String s, Project project) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<PhpNamedElement> signedClasses = new ArrayList<PhpNamedElement>();
if (s.substring(0, 4).equals(CALLTYPE_MOCK))
{
int separator = s.indexOf("~");
String phakeSignature = s.substring(4, separator);
String className = s.substring(separator + 1);
PhpClass phpClass = phpIndex.getClassByName(className);
signedClasses.addAll(phpIndex.getBySignature(phakeSignature));
if (phpClass != null)
{
signedClasses.add(phpClass);
}
else
{
signedClasses.addAll(phpIndex.getInterfacesByName(className));
}
}
else if (s.substring(0, 4).equals(CALLTYPE_VERIFICATION) || s.substring(0, 4).equals(CALLTYPE_STUB))
{
for (String signature : StringUtil.split(s.substring(4),"|"))
{
Collection<? extends PhpNamedElement> phpNamedElements = phpIndex.getBySignature(signature);
signedClasses.addAll(phpNamedElements);
}
}
else if (s.substring(0, 4).equals(CALLTYPE_STUBBED_METHOD))
{
PhpClass answerBinder = phpIndex.getClassByName("Phake_Proxies_AnswerBinderProxy");
signedClasses.add(answerBinder);
}
return signedClasses.size() == 0 ? null : signedClasses;
}
示例3: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private static Collection<PhpClass> getBySignature(String sig, PhpIndex phpIndex, Set<String> visited, @Nullable Set<String> phpIndexVisited, int phpIndexDepth)
{
Collection<PhpClass> classes = new HashSet<>();
for (PhpNamedElement el : phpIndex.getBySignature(sig)) {
classes.addAll(getByType(el.getType(), phpIndex, visited, phpIndexVisited, phpIndexDepth));
}
return classes;
}
示例4: addCompletionForFunctionOptions
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private void addCompletionForFunctionOptions(FunctionReference function, PsiElement element, PsiElement[] givenParameters, CompletionResultSet result) {
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
String signature = function.getSignature();
String[] variants = signature.split("\\|");
for (String variant : variants) {
Collection<? extends PhpNamedElement> bySignature = phpIndex.getBySignature(variant);
for (PhpNamedElement phpNamedElement : bySignature) {
PhpDocComment docComment = phpNamedElement.getDocComment();
if (docComment != null) {
addCompletionForOptions(result, element, givenParameters, docComment.getText());
}
}
}
}
示例5: getResolvedParameter
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
/**
* we can also pipe php references signatures and resolve them here
* overwrite parameter to get string value
*/
@Nullable
public static String getResolvedParameter(PhpIndex phpIndex, String parameter) {
// PHP 5.5 class constant: "Class\Foo::class"
if(parameter.startsWith("#K#C")) {
// PhpStorm9: #K#C\Class\Foo.class
if(parameter.endsWith(".class")) {
return StringUtils.stripStart(parameter.substring(4, parameter.length() - 6), "\\");
}
}
// #K#C\Class\Foo.property
// #K#C\Class\Foo.CONST
if(parameter.startsWith("#")) {
// get psi element from signature
Collection<? extends PhpNamedElement> signTypes = phpIndex.getBySignature(parameter, null, 0);
if(signTypes.size() == 0) {
return null;
}
// get string value
parameter = PhpElementsUtil.getStringValue(signTypes.iterator().next());
if(parameter == null) {
return null;
}
}
return parameter;
}
示例6: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Project project) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
Signature signature = new Signature(expression);
// try to resolve service type
if(ProjectComponent.isEnabled(project) && signature.hasParameter()) {
ArrayList<String> parameters = new ArrayList<String>();
if (Utils.findPimpleContainer(phpIndex, expression, parameters)) {
return phpIndex.getClassesByFQN(getClassNameFromParameters(phpIndex, project, parameters));
}
}
// if it's not a service try to get original type
Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(signature.base, null, 0);
if (collection.size() == 0) {
return Collections.emptySet();
}
// original type can be array (#C\ClassType[]) resolve to proper value type
PhpNamedElement element = collection.iterator().next();
for (String type : element.getType().getTypes()) {
if (type.endsWith("[]")) {
Collection<? extends PhpNamedElement> result = phpIndex.getClassesByFQN(type.substring(0, type.length() - 2));
if (result.size() != 0) {
return result;
}
}
}
return collection;
}
示例7: getResolvedParameter
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public static String getResolvedParameter(PhpIndex phpIndex, String parameter) {
// PHP 5.5 class constant: "Class\Foo::class"
if(parameter.startsWith("#K#C")) {
// PhpStorm9: #K#C\Class\Foo.class
if(parameter.endsWith(".class")) {
return parameter.substring(5, parameter.length() - 6);
}
// PhpStorm8: #K#C\Class\Foo.
// workaround since signature has empty type
if(parameter.endsWith(".")) {
return parameter.substring(5, parameter.length() - 1);
}
}
// #P#C\Class\Foo.property
// #K#C\Class\Foo.CONST
if(parameter.startsWith("#")) {
Collection<? extends PhpNamedElement> signTypes = phpIndex.getBySignature(parameter);
if(signTypes.size() == 0) {
return "";
}
parameter = Utils.getStringValue(signTypes.iterator().next());
if(parameter == null) {
return "";
}
}
return parameter;
}
示例8: assertTypeEquals
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
protected void assertTypeEquals(LanguageFileType languageFileType, @NotNull Class aClass, String configureByText, String phpClassType) {
myFixture.configureByText(languageFileType, configureByText);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
psiElement = PsiTreeUtil.getParentOfType(psiElement, aClass);
if (!(psiElement instanceof PhpReference)) {
fail("Element is not PhpReference.");
}
PhpIndex phpIndex = PhpIndex.getInstance(myFixture.getProject());
Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(((PhpReference)psiElement).getSignature(), null, 0);
assertNotEmpty(collection);
String types = "";
for (String type : collection.iterator().next().getType().getTypes()) {
Collection<? extends PhpNamedElement> col = phpIndex.getBySignature(type, null, 0);
if (col.size() == 0) {
continue;
}
for (String classType : col.iterator().next().getType().getTypes()) {
types = types + classType + '|';
if (classType.equals(phpClassType)) {
return;
}
}
}
fail("Can't find type: "+phpClassType+", found:"+types);
}
示例9: getResolvedParameter
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
/**
* we can also pipe php references signatures and resolve them here
* overwrite parameter to get string value
*/
@Nullable
public static String getResolvedParameter(@NotNull PhpIndex phpIndex, @NotNull String parameter) {
// PHP 5.5 class constant: "Class\Foo::class"
if(parameter.startsWith("#K#C")) {
// PhpStorm9: #K#C\Class\Foo.class
if(parameter.endsWith(".class")) {
return parameter.substring(4, parameter.length() - 6);
}
// PhpStorm8: #K#C\Class\Foo.
// workaround since signature has empty type
if(parameter.endsWith(".")) {
return parameter.substring(4, parameter.length() - 1);
}
}
// #K#C\Class\Foo.property
// #K#C\Class\Foo.CONST
if(parameter.startsWith("#")) {
// get psi element from signature
Collection<? extends PhpNamedElement> signTypes = phpIndex.getBySignature(parameter, null, 0);
if(signTypes.size() == 0) {
return null;
}
// get string value
parameter = PhpElementsUtil.getStringValue(signTypes.iterator().next());
if(parameter == null) {
return null;
}
}
return parameter;
}
示例10: getTypeSignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
/**
* We can have multiple types inside a TypeProvider; split them on "|" so that we dont get empty types
*
* #M#x#M#C\FooBar.get?doctrine.odm.mongodb.document_manager.getRepository|
* #M#x#M#C\FooBar.get?doctrine.odm.mongodb.document_manager.getRepository
*/
@NotNull
public static Collection<? extends PhpNamedElement> getTypeSignature(@NotNull PhpIndex phpIndex, @NotNull String signature) {
if (!signature.contains("|")) {
return phpIndex.getBySignature(signature, null, 0);
}
Collection<PhpNamedElement> elements = new ArrayList<PhpNamedElement>();
for (String s : signature.split("\\|")) {
elements.addAll(phpIndex.getBySignature(s, null, 0));
}
return elements;
}
示例11: getResolvedParameter
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
/**
* we can also pipe php references signatures and resolve them here
* overwrite parameter to get string value
*/
@Nullable
public static String getResolvedParameter(@NotNull PhpIndex phpIndex, @NotNull String parameter) {
// PHP 5.5 class constant: "Class\Foo::class"
if(parameter.startsWith("#K#C")) {
// PhpStorm9: #K#C\Class\Foo.class
if(parameter.endsWith(".class")) {
return StringUtils.stripStart(parameter.substring(4, parameter.length() - 6), "\\");
}
}
// #K#C\Class\Foo.property
// #K#C\Class\Foo.CONST
if(parameter.startsWith("#")) {
// get psi element from signature
Collection<? extends PhpNamedElement> signTypes = phpIndex.getBySignature(parameter, null, 0);
if(signTypes.size() == 0) {
return null;
}
// get string value
parameter = PhpElementsUtil.getStringValue(signTypes.iterator().next());
if(parameter == null) {
return null;
}
}
return parameter;
}
示例12: getTypeSignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
/**
* We can have multiple types inside a TypeProvider; split them on "|" so that we dont get empty types
*
* #M#x#M#C\FooBar.get?doctrine.odm.mongodb.document_manager.getRepository|
* #M#x#M#C\FooBar.get?doctrine.odm.mongodb.document_manager.getRepository
*/
@NotNull
public static Collection<? extends PhpNamedElement> getTypeSignature(@NotNull PhpIndex phpIndex, @NotNull String signature) {
if (!signature.contains("|")) {
return phpIndex.getBySignature(signature, null, 0);
}
Collection<PhpNamedElement> elements = new ArrayList<>();
for (String s : signature.split("\\|")) {
elements.addAll(phpIndex.getBySignature(s, null, 0));
}
return elements;
}
示例13: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {
int endIndex = expression.lastIndexOf(TRIM_KEY);
if(endIndex == -1) {
return Collections.emptySet();
}
String originalSignature = expression.substring(0, endIndex);
String parameter = expression.substring(endIndex + 1);
// search for called method
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<? extends PhpNamedElement> phpNamedElementCollections = phpIndex.getBySignature(originalSignature, null, 0);
if(phpNamedElementCollections.size() == 0) {
return Collections.emptySet();
}
// get first matched item
PhpNamedElement phpNamedElement = phpNamedElementCollections.iterator().next();
if(!(phpNamedElement instanceof Function)) {
return phpNamedElementCollections;
}
parameter = PhpTypeProviderUtil.getResolvedParameter(phpIndex, parameter);
if(parameter == null) {
return phpNamedElementCollections;
}
PhpClass phpClass = PhpElementsUtil.getClassInterface(project, parameter);
if(phpClass != null) {
Collection<PhpClass> phpClasses = new ArrayList<PhpClass>();
phpClasses.add(phpClass);
addExtendsClasses(project, parameter, phpClasses);
return phpClasses;
}
return null;
}
示例14: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {
// get back our original call
// since phpstorm 7.1.2 we need to validate this
int endIndex = expression.indexOf(String.valueOf(TRIM_KEY));
if(endIndex == -1) {
return Collections.emptySet();
}
String originalSignature = expression.substring(0, endIndex);
String parametersSignature = expression.substring(endIndex + 1);
// search for called method
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<? extends PhpNamedElement> phpNamedElements = phpIndex.getBySignature(originalSignature, null, 0);
if(phpNamedElements.size() == 0) {
return Collections.emptySet();
}
// get first matched item
PhpNamedElement phpNamedElement = phpNamedElements.iterator().next();
if(!(phpNamedElement instanceof Function)) {
return phpNamedElements;
}
Map<Integer, String> parameters = getParameters(parametersSignature, phpIndex);
if (parameters.isEmpty()) {
return phpNamedElements;
}
Map<String, Collection<JsonRawLookupElement>> providerMap = ExtensionProviderUtil.getProviders(
project,
ApplicationManager.getApplication().getComponent(PhpToolboxApplicationService.class)
);
Set<Pair<String, Integer>> providers = getProviderNames(project, (Function) phpNamedElement);
Collection<PhpNamedElement> elements = new HashSet<>();
elements.addAll(phpNamedElements);
for (Pair<String, Integer> providerPair : providers) {
String providerName = providerPair.first;
Integer index = providerPair.second;
String parameter = parameters.get(index);
if (parameter == null) {
continue;
}
PhpToolboxProviderInterface provider = ExtensionProviderUtil.getProvider(project, providerName);
if(!(provider instanceof PhpToolboxTypeProviderInterface)) {
continue;
}
PhpToolboxTypeProviderArguments args = new PhpToolboxTypeProviderArguments(
project,
parameter,
providerMap.containsKey(providerName) ? providerMap.get(providerName) : Collections.emptyList()
);
Collection<PhpNamedElement> items = ((PhpToolboxTypeProviderInterface) provider).resolveParameter(args);
if(items != null && items.size() > 0) {
elements.addAll(items);
}
}
return elements;
}
示例15: findPimpleContainer
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private static Boolean findPimpleContainer(PhpIndex phpIndex, String expression, ArrayList<String> parameters, int depth) {
if (++depth > 5) {
return false;
}
Signature signature = new Signature(expression);
Collection<? extends PhpNamedElement> collection;
if (expression.startsWith("#")) {
collection = phpIndex.getBySignature(signature.base, null, 0);
} else {
collection = phpIndex.getClassesByFQN(signature.base);
}
if (collection.size() == 0) {
return false;
}
PhpNamedElement element = collection.iterator().next();
if (element instanceof PhpClass) {
if (Utils.isPimpleContainerClass((PhpClass) element)) {
if (signature.hasParameter()) {
parameters.add(signature.parameter);
}
return true;
}
}
for (String type : element.getType().getTypes()) {
if (findPimpleContainer(phpIndex, type, parameters, depth)) {
if (signature.hasParameter()) {
parameters.add(signature.parameter);
}
return true;
}
}
return false;
}