forked from java-decompiler/jd-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves XML page & indexer : adds hyperlinks on Spring bean declarat…
…ions
- Loading branch information
Showing
9 changed files
with
305 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
services/src/main/groovy/jd/gui/service/indexer/XmlBasedFileIndexerProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (c) 2008-2015 Emmanuel Dupuy | ||
* This program is made available under the terms of the GPLv3 License. | ||
*/ | ||
|
||
package jd.gui.service.indexer | ||
|
||
import groovy.transform.CompileStatic | ||
import jd.gui.api.API | ||
import jd.gui.api.model.Container | ||
import jd.gui.api.model.Indexes | ||
|
||
import javax.xml.stream.XMLInputFactory | ||
import javax.xml.stream.XMLStreamConstants | ||
|
||
class XmlBasedFileIndexerProvider extends AbstractIndexerProvider { | ||
XMLInputFactory factory | ||
|
||
XmlBasedFileIndexerProvider() { | ||
factory = XMLInputFactory.newInstance() | ||
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false) | ||
} | ||
|
||
/** | ||
* @return local + optional external selectors | ||
*/ | ||
String[] getSelectors() { ['*:file:*.xsl', '*:file:*.xslt', '*:file:*.xsd'] + externalSelectors } | ||
|
||
@CompileStatic | ||
void index(API api, Container.Entry entry, Indexes indexes) { | ||
def stringSet = new HashSet<String>() | ||
def reader | ||
|
||
try { | ||
reader = factory.createXMLStreamReader(entry.inputStream) | ||
|
||
stringSet.add(reader.version) | ||
stringSet.add(reader.encoding) | ||
stringSet.add(reader.characterEncodingScheme) | ||
|
||
while (reader.hasNext()) { | ||
switch (reader.next()) { | ||
case XMLStreamConstants.START_ELEMENT: | ||
stringSet.add(reader.localName) | ||
for (int i = reader.attributeCount - 1; i >= 0; i--) { | ||
stringSet.add(reader.getAttributeLocalName(i)) | ||
stringSet.add(reader.getAttributeValue(i)) | ||
} | ||
for (int i = reader.namespaceCount - 1; i >= 0; i--) { | ||
stringSet.add(reader.getNamespacePrefix(i)) | ||
stringSet.add(reader.getNamespaceURI(i)) | ||
} | ||
break | ||
case XMLStreamConstants.PROCESSING_INSTRUCTION: | ||
stringSet.add(reader.getPITarget()) | ||
stringSet.add(reader.getPIData()) | ||
break | ||
case XMLStreamConstants.START_DOCUMENT: | ||
stringSet.add(reader.version) | ||
stringSet.add(reader.encoding) | ||
stringSet.add(reader.characterEncodingScheme) | ||
break | ||
case XMLStreamConstants.ENTITY_REFERENCE: | ||
stringSet.add(reader.localName) | ||
stringSet.add(reader.text) | ||
break | ||
case XMLStreamConstants.ATTRIBUTE: | ||
stringSet.add(reader.prefix) | ||
stringSet.add(reader.namespaceURI) | ||
stringSet.add(reader.localName) | ||
stringSet.add(reader.text) | ||
break | ||
case XMLStreamConstants.COMMENT: | ||
case XMLStreamConstants.DTD: | ||
case XMLStreamConstants.CDATA: | ||
case XMLStreamConstants.CHARACTERS: | ||
stringSet.add(reader.text.trim()) | ||
break | ||
case XMLStreamConstants.NAMESPACE: | ||
for (int i = reader.namespaceCount - 1; i >= 0; i--) { | ||
stringSet.add(reader.getNamespacePrefix(i)) | ||
stringSet.add(reader.getNamespaceURI(i)) | ||
} | ||
break | ||
} | ||
} | ||
} catch (Exception ignore) { | ||
} finally { | ||
reader?.close() | ||
} | ||
|
||
def stringIndex = indexes.getIndex('strings') | ||
|
||
for (def string : stringSet) { | ||
if (string) { | ||
stringIndex.get(string).add(entry) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
services/src/main/groovy/jd/gui/service/treenode/XmlBasedFileTreeNodeFactoryProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2008-2015 Emmanuel Dupuy | ||
* This program is made available under the terms of the GPLv3 License. | ||
*/ | ||
|
||
package jd.gui.service.treenode | ||
|
||
import jd.gui.api.API | ||
import jd.gui.api.feature.UriGettable | ||
import jd.gui.api.model.Container | ||
import jd.gui.view.data.TreeNodeBean | ||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants | ||
|
||
import javax.swing.* | ||
import javax.swing.tree.DefaultMutableTreeNode | ||
|
||
class XmlBasedFileTreeNodeFactoryProvider extends TextFileTreeNodeFactoryProvider { | ||
static final ImageIcon ICON = new ImageIcon(XmlBasedFileTreeNodeFactoryProvider.class.classLoader.getResource('images/xml_obj.gif')) | ||
|
||
/** | ||
* @return local + optional external selectors | ||
*/ | ||
String[] getSelectors() { ['*:file:*.xsl', '*:file:*.xslt', '*:file:*.xsd', '*:file:*.tld', '*:file:*.wsdl'] + externalSelectors } | ||
|
||
public <T extends DefaultMutableTreeNode & UriGettable> T make(API api, Container.Entry entry) { | ||
int lastSlashIndex = entry.path.lastIndexOf('/') | ||
def name = entry.path.substring(lastSlashIndex+1) | ||
return new TreeNode(entry, new TreeNodeBean(label:name, icon:ICON, tip:"Location: $entry.uri.path")) | ||
} | ||
|
||
static class TreeNode extends TextFileTreeNodeFactoryProvider.TreeNode { | ||
TreeNode(Container.Entry entry, Object userObject) { | ||
super(entry, userObject) | ||
} | ||
|
||
public <T extends JComponent & UriGettable> T createPage(API api) { | ||
return new TextFileTreeNodeFactoryProvider.Page(entry) { | ||
String getSyntaxStyle() { | ||
SyntaxConstants.SYNTAX_STYLE_XML | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.