com.intellij.psi.xml.XmlElement的实例源码

项目:magento2-PHPstorm-plugin    文件PHPconstructorargumentCompletionProvider.java   
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,ProcessingContext context,@NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getoriginalElement();
    if (position == null || !(position instanceof XmlElement)) {
        return;
    }


    DiIndex diIndex = DiIndex.getInstance(position.getProject());
    PHPClass PHPClass = diIndex.getPHPClassOfArgument((XmlElement) position);
    if (PHPClass != null) {
        Method constructor = PHPClass.getConstructor();
        if (constructor != null) {
            for (Parameter parameter : constructor.getParameters()) {
                result.addElement(
                        LookupElementBuilder
                                .create(parameter.getName())
                                .withIcon(parameter.getIcon())
                );
            }
        }
    }
}
项目:magento2-PHPstorm-plugin    文件PHPServiceMethodCompletionContributor.java   
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,@NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getoriginalElement();
    if (position == null) {
        return;
    }

    PHPClass PHPClass = DiIndex.getPHPClassOfServiceMethod((XmlElement) position);
    if (PHPClass != null) {
        for (Method method : PHPClass.getmethods()) {
            result.addElement(
                    LookupElementBuilder
                            .create(method.getName())
                            .withIcon(method.getIcon())
            );
        }
    }
}
项目:magento2-PHPstorm-plugin    文件PHPServiceMethodReferenceProvider.java   
@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()]);
}
项目:magento2-PHPstorm-plugin    文件PHPconstructorargumentReferenceProvider.java   
@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;
}
项目:hybris-integration-intellij-idea-plugin    文件BeansUtils.java   
public static <T extends DomElement,V> GenericAttributeValue<V> expectDomAttributeValue(
    @NotNull final PsiElement element,@NotNull final Class<? extends T> domTagClass,@NotNull final Function<T,GenericAttributeValue<V>> domGetter
) {
    final DomManager domManager = DomManager.getDomManager(element.getProject());

    if (!(element instanceof XmlElement)) {
        return null;
    }

    final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(element,XmlAttribute.class,false);
    if (xmlAttribute == null) {
        return null;
    }

    final XmlTag xmlParentTag = PsiTreeUtil.getParentOfType(element,XmlTag.class,false);
    DomElement domParentTag = domManager.getDomElement(xmlParentTag);

    return Optional.ofNullable(domParentTag)
                   .map(o -> ObjectUtils.tryCast(o,domTagClass))
                   .map(domGetter)
                   .filter(val -> val == domManager.getDomElement(xmlAttribute))
                   .orElse(null);
}
项目:hybris-integration-intellij-idea-plugin    文件HybrisItemLineMakerProvider.java   
private void createTargetsWithGutterIcon(
    final Collection<? super RelatedItemLineMarkerInfo> result,final PsiClass psiClass,final Collection<XmlElement> list
) {
    final NavigationGutterIconBuilder builder
        = NavigationGutterIconBuilder.create(HybrisIcons.TYPE_SYstem).setTargets(list);

    builder.setEmptyPopupText(HybrisI18NBundleUtils.message(
        "hybris.gutter.navigate.no.matching.beans",new Object[0]
    ));

    builder.setPopupTitle(HybrisI18NBundleUtils.message(
        "hybris.bean.class.navigate.choose.class.title",new Object[0]
    ));
    builder.setTooltipText(HybrisI18NBundleUtils.message(
        "hybris.item.class.tooltip.navigate.declaration",new Object[0]
    ));
    result.add(builder.createLineMarkerInfo(psiClass.getNameIdentifier()));
}
项目:hybris-integration-intellij-idea-plugin    文件TypeSystemGutterannotator.java   
private static Collection<XmlAttributeValue> findAlternativeDoms(@NotNull final ItemType source) {
    final String code = source.getCode().getStringValue();

    if (StringUtil.isEmpty(code)) {
        return Collections.emptyList();
    }
    final XmlElement element = source.getXmlElement();
    final PsiFile psiFile = element == null ? null : element.getContainingFile();

    if (psiFile == null) {
        return Collections.emptyList();
    }
    final TSmetamodel externalModel = TSmetamodelAccess.getInstance(psiFile.getProject()).
        getExternalTypeSystemMeta(psiFile);

    return Optional.ofNullable(externalModel.findMetaClassForDom(source))
                   .map(TSMetaClass::retrieveAllDomsstream)
                   .orElse(Stream.empty())
                   .filter(dom -> !dom.equals(source))
                   .map(ItemType::getCode)
                   .map(GenericAttributeValue::getXmlAttributeValue)
                   .collect(Collectors.toList());
}
项目:hybris-integration-intellij-idea-plugin    文件TypeSystemGutterannotator.java   
@NotNull
private static Stream<TSMetaClass> getExtendingMetaClassNamesstream(@NotNull final ItemType source) {
    final String code = source.getCode().getStringValue();

    if (StringUtil.isEmpty(code)) {
        return Stream.empty();
    }
    final XmlElement xmlElement = source.getXmlElement();
    final PsiFile psiFile = xmlElement == null ? null : xmlElement.getContainingFile();

    if (psiFile == null) {
        return Stream.empty();
    }
    final TSmetamodel metamodel = TSmetamodelAccess.getInstance(psiFile.getProject()).getTypeSystemMeta(psiFile);
    final TSMetaClass sourceMeta = metamodel.findMetaClassForDom(source);

    if (sourceMeta == null) {
        return Stream.empty();
    }
    return metamodel
        .getMetaClassesstream()
        .map(TSMetaClass.class::cast)
        .filter(Meta -> sourceMeta.getName().equals(Meta.getExtendedMetaClassName()));
}
项目:ReactPropTypes-Plugin    文件CommonAction.java   
@Nullable
private JSFunction getSelectStatelessComponent(String selectText,PsiFile file){
  return PsiTreeUtil.findChildrenOfType(file,JSFunction.class)
          .stream()
          .filter(o -> o.getName()!=null && o.getName().equals(selectText))
          .filter(o -> {
            XmlElement element = PsiTreeUtil.findChildrenOfType(o,XmlElement.class)
                    .stream()
                    .findFirst()
                    .orElse(null);
            return  element != null;
          })
          .findFirst()
          .orElse(null);

}
项目:catBerry-idea-plugin    文件CatBerryAttributeDescriptor.java   
@Override
public PsiElement getValueDeclaration(XmlElement xmlElement,String value) {
  CatBerryProjectConfigurationManager configurationManager = CatBerryProjectConfigurationManager.getInstance(project);
  PsiDirectory directory = configurationManager.getStoresDirectory();
  if(directory == null)
    return super.getValueDeclaration(xmlElement,value);
  final String requiredPath = directory.getVirtualFile().getPath() + "/" + value+".js";

  int index = value.lastIndexOf('/');
  String className = index == -1 ? value : value.substring(index+1);
  Collection<JSElement> elements = StubIndex.getElements(JSClassIndex.KEY,className,project,GlobalSearchScope.allScope(project),JSElement.class);

  for(JSElement element : elements) {
    if (element instanceof JSClass &&  element.getContainingFile().getVirtualFile().getPath().equals(requiredPath))
      return element;
  }
  return super.getValueDeclaration(xmlElement,value);
}
项目:intellij-ce-playground    文件BasicSelectioner.java   
public static boolean canSelectBasic(final PsiElement e) {
  return
    !(e instanceof PsiWhiteSpace) &&
    !(e instanceof PsiComment) &&
    !(e instanceof PsiCodeBlock) &&
    !(e instanceof PsiArrayInitializerExpression) &&
    !(e instanceof PsiParameterList) &&
    !(e instanceof PsiExpressionList) &&
    !(e instanceof PsiBlockStatement) &&
    !(e instanceof PsiJavaCodeReferenceElement) &&
    !(e instanceof PsiJavaToken &&
    !(e instanceof PsiKeyword)) &&
    !(e instanceof XmlToken) &&
    !(e instanceof XmlElement) &&
    !(e instanceof PsiDocTag);
}
项目:intellij-ce-playground    文件XPathEvalAction.java   
/**
 * Opens an input Box to input an XPath expression. The Box will have a history dropdown from which
 * prevIoUsly entered expressions can be selected.
 * @return The expression or <code>null</code> if the user hits the cancel button
 * @param project The project to take the history from
 */
@Nullable
private EvalExpressionDialog.Context inputXPathExpression(final Project project,XmlElement contextNode) {
    final XPathProjectComponent pc = XPathProjectComponent.getInstance(project);
    LOG.assertTrue(pc != null);

    // get expression history from project component
    final HistoryElement[] history = pc.getHistory();

    final EvalExpressionDialog dialog = new EvalExpressionDialog(project,myComponent.getConfig(),history);
    if (!dialog.show(contextNode)) {
        // cancel
        LOG.debug("Input canceled");
        return null;
    }

    final InputExpressionDialog.Context context = dialog.getContext();
    LOG.debug("expression = " + context.input.expression);

    pc.addHistory(context.input);

    return context;
}
项目:intellij-ce-playground    文件XPathEvalAction.java   
private void showUsageView(final Editor editor,final XPath xPath,final XmlElement contextNode,final List<?> result) {
    final Project project = editor.getProject();

    //noinspection unchecked
    final List<?> _result = new ArrayList(result);
    final Factory<UsageSearcher> searcherFactory = new Factory<UsageSearcher>() {
        @Override
        public UsageSearcher create() {
            return new MyUsageSearcher(_result,xPath,contextNode);
        }
    };
    final MyUsageTarget usageTarget = new MyUsageTarget(xPath.toString(),contextNode);

    showUsageView(project,usageTarget,searcherFactory,new EditExpressionAction() {
        final Config config = myComponent.getConfig();

        @Override
        protected void execute() {
            XPathEvalAction.this.execute(editor);
        }
    });
}
项目:intellij-ce-playground    文件MavendomUtil.java   
public static int getCollectionIndex(@NotNull final MavendomDependencies dependencies,@Nullable final Editor editor) {
  if (editor != null) {
    int offset = editor.getCaretModel().getoffset();

    List<MavendomDependency> dependencyList = dependencies.getDependencies();

    for (int i = 0; i < dependencyList.size(); i++) {
      MavendomDependency dependency = dependencyList.get(i);
      XmlElement xmlElement = dependency.getXmlElement();

      if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) {
        return i;
      }
    }
  }
  return -1;
}
项目:intellij-ce-playground    文件AntResolveinspection.java   
@NotNull
private static Collection<PropertiesFile> getPropertyFiles(@Nullable AntDomProject antDomProject,@NotNull XmlElement stopElement) {
  if (antDomProject == null) {
    return Collections.emptyList();
  }
  final Set<PropertiesFile> files = new java.util.HashSet<PropertiesFile>();
  final int stopOffset = stopElement.getTextOffset();

  for (Iterator<AntDomElement> iterator = antDomProject.getAntChildrenIterator(); iterator.hasNext(); ) {
    AntDomElement child = iterator.next();
    final XmlElement xmlElement = child.getXmlElement();
    if (xmlElement != null && xmlElement.getTextOffset() >= stopOffset) {
      break; // no need to offer to add properties to files that are imported after the property reference
    }
    if (child instanceof AntDomProperty) {
      final AntDomProperty property = (AntDomProperty)child;
      final PropertiesFile file = property.getPropertiesFile();
      if (file != null) {
        files.add(file);
      }
    }
  }
  return files;
}
项目:intellij-ce-playground    文件XsdEnumerationDescriptor.java   
private boolean processEnumeration(XmlElement context,PairProcessor<PsiElement,String> processor,boolean forCompletion) {
  XmlTag contextTag = context != null ? PsiTreeUtil.getContextOfType(context,false) : null;
  final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)XmlUtil.findXmlDescriptorByType(getDeclaration(),contextTag);

  if (elementDescriptor!=null && elementDescriptor.getType() instanceof ComplexTypeDescriptor) {
    return processEnumerationImpl(((ComplexTypeDescriptor)elementDescriptor.getType()).getDeclaration(),processor,forCompletion);
  }

  final String namespacePrefix = getDeclaration().getNamespacePrefix();
  XmlTag type = getDeclaration().findFirstSubTag(
    ((namespacePrefix.length() > 0) ? namespacePrefix + ":" : "") + "simpleType"
  );

  if (type != null) {
    return processEnumerationImpl(type,forCompletion);
  }

  return false;
}
项目:intellij-ce-playground    文件XsltNamespaceContext.java   
public static Collection<String> getPrefixes(XmlElement context) {
    final XmlTag tag = PsiTreeUtil.getParentOfType(context,XmlTag.class);
    if (tag != null) {
        final HashSet<String> allPrefixes = new HashSet<String>();
        final String[] uris = tag.kNownNamespaces();
        for (String uri : uris) {
            for (XmlTag p = tag; p != null; p = p.getParentTag()) {
                final Set<Map.Entry<String,String>> localPrefixes = p.getLocalNamespaceDeclarations().entrySet();
                for (Map.Entry<String,String> entry : localPrefixes) {
                    final String prefix = entry.getKey();
                    if (!prefix.isEmpty() && entry.getValue().equals(uri)) {
                        if (!allPrefixes.contains(prefix)) {
                            allPrefixes.add(prefix);
                        }
                    }
                }
            }
        }
        return allPrefixes;
    } else {
        return Collections.emptySet();
    }
}
项目:intellij-ce-playground    文件XmlTextTest.java   
public void testInsertAtOffset() throws Exception {
  new WriteCommandAction(getProject()) {

    @Override
    protected void run(@NotNull final Result result) throws Throwable {
      String xml = "<root>0123456789</root>";
      XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject())
        .createFileFromText("foo.xml",StdFileTypes.XML,xml,(long)1,true,false);
      //System.out.println(DebugUtil.psiToString(file,false));
      XmlTag root = file.getDocument().getRoottag();
      final XmlText text1 = root.getValue().getTextElements()[0];

      assertFalse(CodeEditUtil.isNodeGenerated(root.getNode()));
      final XmlText text = text1;

      final XmlElement element = text.insertAtOffset(XmlElementFactory.getInstance(getProject()).createTagFromText("<bar/>"),5);
      assertNotNull(element);
      assertTrue(element instanceof XmlText);
      assertEquals("01234",element.getText());
      assertEquals("<root>01234<bar/>56789</root>",text.getContainingFile().getText());
    }
  }.execute();
}
项目:intellij-ce-playground    文件XmlElementImpl.java   
@Nullable
protected static String getNameFromEntityRef(final CompositeElement compositeElement,final IElementType xmlEntityDeclStart) {
  final ASTNode node = compositeElement.findChildByType(xmlEntityDeclStart);
  if (node == null) return null;
  ASTNode name = node.getTreeNext();

  if (name != null && name.getElementType() == TokenType.WHITE_SPACE) {
    name = name.getTreeNext();
  }

  if (name != null && name.getElementType() == XmlElementType.XML_ENTITY_REF) {
    final StringBuilder builder = new StringBuilder();

    ((XmlElement)name.getPsi()).processElements(new PsiElementProcessor() {
      @Override
      public boolean execute(@NotNull final PsiElement element) {
        builder.append(element.getText());
        return true;
      }
    },name.getPsi());
    if (builder.length() > 0) return builder.toString();
  }
  return null;
}
项目:intellij-ce-playground    文件InputExpressionDialog.java   
@SuppressWarnings({"unchecked"})
private void prepareShow(XmlElement contextElement) {

    final NamespaceCollector.CollectedInfo collectedInfo;
    if (contextElement != null) {
        collectedInfo = NamespaceCollector.collectInfo((XmlFile)contextElement.getContainingFile());
        myNamespaceCache = collectedInfo.namespaces;
    } else {
        collectedInfo = NamespaceCollector.empty();
        myNamespaceCache = null;
    }

    myContextProvider = new InteractiveContextProvider(contextElement,collectedInfo,myModel);
    myContextProvider.attachTo(myXPathFile);

    final HistoryElement historyElement = myModel.getSelectedItem();
    if (historyElement != null) {
        myContextProvider.getNamespaceContext().setMap(asMap(historyElement.namespaces));
    } else {
        myContextProvider.getNamespaceContext().setMap(asMap(null));
    }

    updateOkAction();
}
项目:AppleScript-IDEA    文件DictionaryIdentifierImpl.java   
public DictionaryIdentifierImpl(@NotNull DictionaryComponent myParent,@NotNull String varIdentifierText,@NotNull XmlElement myXmlAttributeValue) {
  super(myXmlAttributeValue,myParent);
  this.varIdentifierText = varIdentifierText;
  varIdentifierTextList = new ArrayList<>(Arrays.asList(varIdentifierText.split(" ")));
  myVarIdentifier = new DictionaryIdentifierImpl(myParent,varIdentifierTextList.get(0),myXmlElement);
}
项目:hybris-integration-intellij-idea-plugin    文件TsstructureTreeElement.java   
private String localizeDescription(final DomElement dom) {
    if (dom instanceof Description) {
        final XmlElement xmlElement = dom.getXmlElement();
        if (xmlElement instanceof XmlTag) {
            final XmlTagValue value = ((XmlTag) xmlElement).getValue();
            if (value != null) {
                return value.getTrimmedText();
            }
        }
    }
    return null;
}
项目:intellij-ce-playground    文件ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element,final DomElementAnnotationHolder holder) {
  if (!isPsiClasstype(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final XmlElement valueElement = DomUtil.getValueElement(element);
  if (valueElement == null) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(valueElement,new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getoptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element,((PsiClass)valueObject),false,holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件InputExpressionDialog.java   
@SuppressWarnings({ "unchecked" })
public boolean show(XmlElement contextElement) {
    prepareShow(contextElement);

    show();

    return isOK();
}
项目:intellij-ce-playground    文件DomElementAnnotationHolderImpl.java   
@Override
@NotNull
public Annotation createAnnotation(@NotNull DomElement element,HighlightSeverity severity,@Nullable String message) {
  final XmlElement xmlElement = element.getXmlElement();
  LOG.assertTrue(xmlElement != null,"No XML element for " + element);
  final TextRange range = xmlElement.getTextRange();
  final int startOffset = range.getStartOffset();
  final int endOffset = message == null ? startOffset : range.getEndOffset();
  final Annotation annotation = new Annotation(startOffset,endOffset,severity,message,null);
  myAnnotations.add(annotation);
  return annotation;
}
项目:intellij-ce-playground    文件ShowXPathAction.java   
protected boolean isEnabledAt(XmlFile xmlFile,int offset) {
    final PsiElement element = xmlFile.findElementAt(offset);
    if (!(element instanceof XmlElement || element instanceof PsiWhiteSpace)) {
        return false;
    }

    final PsiElement node = XPathExpressionGenerator.transformTovalidShowPathNode(element);
    return node != null;
}
项目:intellij-ce-playground    文件CompletionLists.java   
private static void addNamespaceCompletions(NamespaceContext namespaceContext,Set<Lookup> list,XmlElement context) {
  if (namespaceContext != null) {
    final Collection<String> kNownPrefixes = namespaceContext.getKNownPrefixes(context);
    for (String prefix : kNownPrefixes) {
      if (prefix != null && prefix.length() > 0) {
        list.add(new NamespaceLookup(prefix));
      }
    }
  }
}
项目:intellij-ce-playground    文件DomTestCase.java   
protected void assertCached(final DomElement element,final XmlElement xmlElement) {
  assertNotNull(xmlElement);
  assertSame(element.getXmlTag(),xmlElement);
  final DomInvocationHandler cachedElement = getCachedHandler(xmlElement);
  assertNotNull(cachedElement);
  assertEquals(element,cachedElement.getProxy());
}
项目:intellij-ce-playground    文件EnumConverter.java   
@Override
@NotNull
public Collection<? extends T> getvariants(final ConvertContext context) {
  final XmlElement element = context.getXmlElement();
  if (element instanceof XmlTag) {
    final XmlTag simpleContent = XmlUtil.getSchemaSimpleContent((XmlTag)element);
    if (simpleContent != null && XmlUtil.collectEnumerationValues(simpleContent,new HashSet<String>())) {
      return Collections.emptyList();
    }
  }
  return Arrays.asList(myType.getEnumConstants());
}
项目:intellij-ce-playground    文件IndexedElementInvocationHandler.java   
@Override
protected XmlElement recomputeXmlElement(@NotNull final DomInvocationHandler parentHandler) {
  final XmlTag tag = parentHandler.getXmlTag();
  if (tag == null) return null;

  final List<XmlTag> tags = DomImplUtil.findSubTags(tag,getXmlName(),parentHandler.getFile());
  if (tags.size() <= myIndex) return null;

  return tags.get(myIndex);
}
项目:intellij-ce-playground    文件Xslt2ContextProvider.java   
@Override
@NotNull
public FunctionContext createFunctionContext() {
  final XmlElement contextElement = getContextElement();
  return contextElement != null && contextElement.isValid() ?
          functionContextCache.get((XmlFile)contextElement.getContainingFile(),null) :
          Xslt2FunctionContext.getInstance();
}
项目:intellij-ce-playground    文件AntDomTargetDependsListConverter.java   
@NotNull
public PsiReference[] createReferences(GenericDomValue<TargetResolver.Result> value,PsiElement element,ConvertContext context) {
  final XmlElement xmlElement = value.getXmlElement();
  if (!(xmlElement instanceof XmlAttribute)) {
    return PsiReference.EMPTY_ARRAY;
  }
  final XmlAttributeValue valueElement = ((XmlAttribute)xmlElement).getValueElement();
  if (valueElement == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final String refsstring = value.getStringValue();
  if (refsstring == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final List<PsiReference> refs = new ArrayList<PsiReference>();
  final AntDomTargetReference.ReferenceGroup group = new AntDomTargetReference.ReferenceGroup();
  final TextRange wholeStringRange = ElementManipulators.getValueTextRange(valueElement);
  final StringTokenizer tokenizer = new StringTokenizer(refsstring,",false);
  while (tokenizer.hasMoretokens()) {
    final String token = tokenizer.nextToken();
    int tokenStartOffset = tokenizer.getCurrentPosition() - token.length();
    final String ref = token.trim();
    if (ref.length() != token.length()) {
      for (int idx = 0; idx < token.length(); idx++) {
        if (Character.isWhitespace(token.charat(idx))) {
          tokenStartOffset++;
        }
        else {
          break;
        }
      }
    }
    refs.add(new AntDomTargetReference(element,TextRange.from(wholeStringRange.getStartOffset() + tokenStartOffset,ref.length()),group));
  }
  return refs.toArray(new PsiReference[refs.size()]);
}
项目:intellij-ce-playground    文件DependencyConfigFileConverter.java   
@Override
public PathReference fromString(@Nullable String s,ConvertContext context) {
  final XmlElement element = context.getXmlElement();
  final Module module = context.getModule();
  if (s == null || element == null || module == null) {
    return null;
  }
  return PathReferenceManager.getInstance().getCustomPathReference(s,module,element,ourProvider);
}
项目:intellij-ce-playground    文件ExtractManagedDependenciesAction.java   
private static PsiFile[] getFiles(@NotNull PsiFile file,@NotNull MavendomProjectModel model,@NotNull Set<MavendomDependency> usages) {
  Set<PsiFile> files = new HashSet<PsiFile>();

  files.add(file);
  XmlElement xmlElement = model.getXmlElement();
  if (xmlElement != null) files.add(xmlElement.getContainingFile());
  for (MavendomDependency usage : usages) {
    XmlElement element = usage.getXmlElement();
    if (element != null) {
      files.add(element.getContainingFile());
    }
  }

  return PsiUtilCore.toPsiFileArray(files);
}
项目:intellij-ce-playground    文件DomManagerImpl.java   
@Nullable
public final DomFileDescription<?> getDomFileDescription(PsiElement element) {
  if (element instanceof XmlElement) {
    final PsiFile psiFile = element.getContainingFile();
    if (psiFile instanceof XmlFile) {
      return getDomFileDescription((XmlFile)psiFile);
    }
  }
  return null;
}
项目:intellij-ce-playground    文件ResourceReferenceConverter.java   
@Nullable
static String getValue(XmlElement element) {
  if (element instanceof XmlAttribute) {
    return ((XmlAttribute)element).getValue();
  }
  else if (element instanceof XmlTag) {
    return ((XmlTag)element).getValue().getText();
  }
  return null;
}
项目:intellij-ce-playground    文件AntDomProject.java   
@Nullable
public PsiElement getNavigationElement(String propertyName) {
  final DomTarget target = DomTarget.getTarget(this);
  final PsiElement nameElementPsi = target != null ? PomService.convertToPsi(target) : null;
  if (nameElementPsi != null) {
    return nameElementPsi;
  }
  final XmlElement xmlElement = getXmlElement();
  return xmlElement != null? xmlElement.getNavigationElement() : null;
}
项目:intellij-ce-playground    文件PhysicalDomParentStrategy.java   
public static boolean strategyEquals(DomParentStrategy strategy,final Object o) {

    if (strategy == o) return true;
    if (!(o instanceof DomParentStrategy)) return false;
    final XmlElement thatElement = ((DomParentStrategy)o).getXmlElement();
    if (thatElement == null) return false;
    XmlElement element = strategy.getXmlElement();
    if (element == null) return false;

    if (xmlElementsEqual(element,thatElement)) {
      if (element != thatElement) {
        final PsiElement nav1 = element.getNavigationElement();
        final PsiElement nav2 = thatElement.getNavigationElement();
        if (nav1 != nav2) {
          PsiElement curContext = findIncluder(element);
          PsiElement navContext = findIncluder(nav1);
          LOG.error(LogMessageEx.createEvent(
            "x:include processing error","nav1,nav2=" + nav1 + "," + nav2 + ";\n" +
            nav1.getContainingFile() + ":" + nav1.getTextRange().getStartOffset() + "!=" + nav2.getContainingFile() + ":" + nav2.getTextRange().getStartOffset() + ";\n" +
            (nav1 == element) + ";" + (nav2 == thatElement) + ";\n" +
            "contexts equal: " +  (curContext == navContext) + ";\n" +
            "curContext?.physical=" + (curContext != null && curContext.isPhysical()) + ";\n" +
            "navContext?.physical=" + (navContext != null && navContext.isPhysical()) + ";\n" +
            "myElement.physical=" + element.isPhysical() + ";\n" +
            "thatElement.physical=" + thatElement.isPhysical() + "\n" + DebugUtil.currentStackTrace(),new Attachment("Including tag text 1.xml",curContext == null ? "null" : curContext.getText()),new Attachment("Including tag text 2.xml",navContext == null ? "null" : navContext.getText())
          ));
          throw new AssertionError();
        }
      }
      return true;
    }
    return false;
  }
项目:intellij-ce-playground    文件DomPatterns.java   
/**
 * @deprecated use {@link #tagWithDom(String,ElementPattern)} and  {@link #attributeWithDom(String,ElementPattern)}
 */
public static XmlElementPattern.Capture withDom(final ElementPattern<? extends DomElement> pattern) {
  return new XmlElementPattern.Capture().with(new PatternCondition<XmlElement>("tagWithDom") {
    @Override
    public boolean accepts(@NotNull final XmlElement xmlElement,final ProcessingContext context) {
      final DomManager manager = DomManager.getDomManager(xmlElement.getProject());
      if (xmlElement instanceof XmlAttribute) {
        return pattern.accepts(manager.getDomElement((XmlAttribute)xmlElement),context);
      }
      return xmlElement instanceof XmlTag && pattern.accepts(manager.getDomElement((XmlTag)xmlElement),context);
    }
  });
}
项目:intellij-ce-playground    文件QNameUtil.java   
public static QName createQName(@NotNull String qname,@NotNull PsiElement context) {
    final String[] strings = qname.split(":",2);
    if (strings.length == 1) {
        return new QName(null,qname);
    }
    final XmlElement ctx = PsiTreeUtil.getParentOfType(context,XmlElement.class,false);
    if (ctx == null) return UNRESOLVED;
    final String uri = XsltNamespaceContext.getNamespaceUriStatic(strings[0],ctx);
    if (uri == null) return UNRESOLVED;

    return new QName(uri,strings[1],strings[0]);
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...