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


Java StringUtil.unquoteString方法代碼示例

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


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

示例1: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    if (!(element instanceof XmlElement)) {
        return PsiReference.EMPTY_ARRAY;
    }

    List<PsiReference> psiReferences = new ArrayList<>();

    String methodName = StringUtil.unquoteString(element.getText());

    PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) element);
    if (phpClass != null) {
        Collection<Method> methods = phpClass.getMethods();
        methods.removeIf(m -> !m.getName().equalsIgnoreCase(methodName));
        psiReferences.add(new PolyVariantReferenceBase(element, methods));
    }

    return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:21,代碼來源:PhpServiceMethodReferenceProvider.java

示例2: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {

    String value = StringUtil.unquoteString(element.getText());

    DiIndex index = DiIndex.getInstance(element.getProject());
    Collection<PsiElement> targets = index.getVirtualTypeElements(value, element.getResolveScope());

    if (!(targets.size() > 0)) {
        return PsiReference.EMPTY_ARRAY;
    }

    return new PsiReference[] {
            new PolyVariantReferenceBase(element, targets)
    };
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:18,代碼來源:VirtualTypeReferenceProvider.java

示例3: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    Collection<PsiElement> targets = EventIndex.getInstance(element.getProject())
            .getEventElements(
                    value,
                    GlobalSearchScope.getScopeRestrictedByFileTypes(
                            GlobalSearchScope.allScope(element.getProject()),
                            XmlFileType.INSTANCE
                    )
    );

    if (targets.size() > 0) {
        return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
    }
    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:19,代碼來源:EventDispatchReferenceProvider.java

示例4: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {

    String parameterName = StringUtil.unquoteString(element.getText());
    if (parameterName.isEmpty() || !(element instanceof XmlElement)) {
        return PsiReference.EMPTY_ARRAY;
    }


    DiIndex diIndex = DiIndex.getInstance(element.getProject());
    PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) element);
    if (phpClass != null) {
        Method constructor = phpClass.getConstructor();
        if (constructor != null) {
            Collection<Parameter> parameterList = new THashSet<>(Arrays.asList(constructor.getParameters()));
            parameterList.removeIf(p -> !p.getName().contains(parameterName));
            if (parameterList.size() > 0) {
                return new PsiReference[] {new PolyVariantReferenceBase(element, parameterList)};
            }
        }
    }

    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:26,代碼來源:PhpConstructorArgumentReferenceProvider.java

示例5: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(EventNameIndex.KEY, value,
                GlobalSearchScope.getScopeRestrictedByFileTypes(
                        GlobalSearchScope.allScope(element.getProject()),
                        PhpFileType.INSTANCE
                )
        );

    PsiManager psiManager = PsiManager.getInstance(element.getProject());
    for (VirtualFile virtualFile: containingFiles) {
        PhpFile phpFile = (PhpFile) psiManager.findFile(virtualFile);
        if (phpFile != null) {
            List<PsiElement> psiElements = new ArrayList<>();
            recursiveFill(psiElements, phpFile, value);
            if (psiElements.size() > 0) {
                return new PsiReference[] {new PolyVariantReferenceBase(element, psiElements)};
            }
        }
    }
    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:26,代碼來源:EventNameReferenceProvider.java

示例6: recursiveFill

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
private void recursiveFill(List<String> results, PsiElement psiElement) {
    if (PhpPatternsHelper.STRING_METHOD_ARGUMENT.accepts(psiElement) && isInContextOfDispatchMethod(psiElement)) {
        String eventName= StringUtil.unquoteString(psiElement.getText());
        if (eventName.length() > 0) {
            results.add(eventName);
        }
        return;
    }
    for(PsiElement child: psiElement.getChildren()) {
        recursiveFill(results, child);
    }
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:13,代碼來源:EventNameIndex.java

示例7: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    List<PsiReference> psiReferences = new ArrayList<>();
    final Collection<PhpClassMember> members = new THashSet<>();

    String origValue = element.getText();
    String value = StringUtil.unquoteString(element.getText());

    Matcher matcher = Pattern.compile(PhpRegex.Xml.CLASS_MEMBER_NAME).matcher(value);
    if (!matcher.find()) {
        return PsiReference.EMPTY_ARRAY;
    }

    String elementName = matcher.group(1);
    String classFQN = value.substring(0, value.lastIndexOf("::"));

    PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
    for (final PhpClass phpClass : phpIndex.getAnyByFQN(classFQN)) {
        members.addAll(phpClass.getFields());
        members.addAll(phpClass.getMethods());
        members.removeIf(c -> !c.getName().equals(elementName));
    }

    if (members.size() > 0) {
        TextRange range = new TextRange(
                origValue.indexOf(elementName),
                origValue.indexOf(elementName) + elementName.length()
        );
        psiReferences.add(new PolyVariantReferenceBase(element, range, members));
    }
    return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:34,代碼來源:PhpClassMemberReferenceProvider.java

示例8: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    List<XmlTag> targets = LayoutIndex.getContainerDeclarations(value, element.getProject());
    if (targets.size() > 0) {
        return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
    }
    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:11,代碼來源:LayoutContainerReferenceProvider.java

示例9: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    List<XmlFile> targets = LayoutIndex.getLayoutFiles(element.getProject(), value);
    if (targets.size() > 0) {
        return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
    }
    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:11,代碼來源:LayoutUpdateReferenceProvider.java

示例10: getReferencesByElement

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    List<XmlTag> targets = LayoutIndex.getBlockDeclarations(value, element.getProject());
    if (targets.size() > 0) {
        return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
    }
    return PsiReference.EMPTY_ARRAY;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:11,代碼來源:LayoutBlockReferenceProvider.java

示例11: findTargetFeature

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
private static PsiElement findTargetFeature( PsiAnnotation psiAnnotation, ManifoldPsiClass facade )
  {
    PsiAnnotationMemberValue value = psiAnnotation.findAttributeValue( SourcePosition.FEATURE );
    String featureName = StringUtil.unquoteString( value.getText() );
//    value = psiAnnotation.findAttributeValue( SourcePosition.TYPE );
//    if( value != null )
//    {
//      String ownersType = StringUtil.unquoteString( value.getText() );
//      if( ownersType != null )
//      {
//        PsiElement target = findIndirectTarget( ownersType, featureName, facade.getRawFile().getProject() );
//        if( target != null )
//        {
//          return target;
//        }
//      }
//    }

    int iOffset = Integer.parseInt( psiAnnotation.findAttributeValue( SourcePosition.OFFSET ).getText() );
    int iLength = Integer.parseInt( psiAnnotation.findAttributeValue( SourcePosition.LENGTH ).getText() );

    List<PsiFile> sourceFiles = facade.getRawFiles();
    if( iOffset >= 0 )
    {
      //PsiElement target = sourceFile.findElementAt( iOffset );
      //## todo: handle multiple files
      return new FakeTargetElement( sourceFiles.get( 0 ), iOffset, iLength >= 0 ? iLength : 1, featureName );
    }
    return facade;
  }
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:31,代碼來源:ManGotoDeclarationHandler.java

示例12: getIndexer

import com.intellij.openapi.util.text.StringUtil; //導入方法依賴的package包/類
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
    return inputData -> {
        Map<String, String> map = new HashMap<>();
        PsiFile psiFile = inputData.getPsiFile();

        if (!Settings.isEnabled(psiFile.getProject())) {
            return map;
        }

        if (psiFile instanceof PhpFile) {
            MethodReference  method = PsiTreeUtil.findChildOfAnyType(psiFile, MethodReference.class);
            if (method != null) {
                ParameterList parameterList = method.getParameterList();
                if (parameterList != null) {
                    PsiElement firstParameter = parameterList.getFirstPsiChild();
                    if (firstParameter != null && firstParameter instanceof ClassConstantReference) {
                        String constantName = ((ClassConstantReference) firstParameter).getName();
                        if (constantName != null) {
                            PsiElement moduleNameEl = ((ClassConstantReference) firstParameter).getNextPsiSibling();
                            if (moduleNameEl != null && moduleNameEl instanceof StringLiteralExpression) {
                                String moduleName = StringUtil.unquoteString(moduleNameEl.getText());

                                PsiElement modulePathEl =
                                        ((StringLiteralExpression) moduleNameEl).getNextPsiSibling();
                                if (modulePathEl != null) {
                                    Pattern pattern = Pattern.compile(
                                            "__DIR__(\\s*[.,]\\s*[\\'\\\"]((/[\\w-]+)+)/?[\\'\\\"])?"
                                    );
                                    Matcher matcher = pattern.matcher(modulePathEl.getText());
                                    if (matcher.find()) {
                                        String modulePath = matcher.group(2);
                                        map.put(
                                                moduleName,
                                                modulePath == null ? "" : modulePath
                                        );
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return map;
    };
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:50,代碼來源:ModuleNameIndex.java


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