コード例 #1
0
 private int[] getOffsetOfElement(IBundle bundle, IManifestHeader header, String value) {
   int[] offlen = new int[] {0, 0};
   IBundleModel model = bundle.getModel();
   if (model instanceof IEditingModel) {
     IDocument pDoc = ((IEditingModel) model).getDocument();
     int headerOffset = header.getOffset() + header.getName().length();
     try {
       String headerString =
           pDoc.get(headerOffset, header.getLength() - header.getName().length());
       int internalOffset = headerString.indexOf(value);
       if (internalOffset != -1) offlen[0] = headerOffset + internalOffset;
       else
         offlen[0] = headerOffset + header.getName().length() + header.getValue().indexOf(value);
       offlen[1] = value.length();
     } catch (BadLocationException e) {
     }
   }
   return offlen;
 }
コード例 #2
0
 private void inspectBundle(IBundle bundle) {
   for (int i = 0; i < H_TOTAL; i++) {
     if (fSearchFor == S_FOR_TYPES && (i == H_IMP || i == H_EXP)) continue;
     IManifestHeader header = bundle.getManifestHeader(SEARCH_HEADERS[i]);
     if (header != null) {
       try {
         ManifestElement[] elements =
             ManifestElement.parseHeader(header.getName(), header.getValue());
         if (elements == null) continue;
         for (int j = 0; j < elements.length; j++) {
           String value = null;
           Matcher matcher = null;
           if (fSearchFor == S_FOR_TYPES) {
             value = elements[j].getValue();
             matcher = getMatcher(value);
           }
           if (value == null || (matcher != null && !matcher.matches())) {
             value = getProperValue(elements[j].getValue());
             matcher = getMatcher(value);
           }
           if (matcher.matches()) {
             String group = matcher.group(0);
             int[] offlen;
             offlen = getOffsetOfElement(bundle, header, group);
             fSearchRequestor.reportMatch(
                 new Match(
                     bundle.getModel().getUnderlyingResource(),
                     Match.UNIT_CHARACTER,
                     offlen[0],
                     offlen[1]));
             break; // only one package will be listed per header
           }
         }
       } catch (BundleException e) {
       }
     }
   }
 }