mirror of
https://github.com/revanced/smali.git
synced 2025-04-29 22:24:26 +02:00
Remove smalidea from the smali repository
It has been split out into a separate smalidea repository
This commit is contained in:
parent
5339a81f0f
commit
b761c5f089
22
NOTICE
22
NOTICE
@ -30,7 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
|
|
||||||
Unless otherwise stated in the code/commit message, any changes with the
|
Unless otherwise stated in the code/commit message, any changes with the
|
||||||
committer of bgruv@google.com or wkal@google.com is copyrighted by
|
committer of bgruv@google.com or wkal@google.com is copyrighted by
|
||||||
Google Inc. and released under the following license:
|
Google Inc. and released under the following license:
|
||||||
|
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
@ -77,26 +77,6 @@ You may obtain a copy of the License at
|
|||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*******************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
Some parts of the smalidea plugin are based on code from the IDEA project, per the
|
|
||||||
following license
|
|
||||||
|
|
||||||
*******************************************************************************
|
|
||||||
Copyright 2000-2014 JetBrains s.r.o.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -1,5 +1 @@
|
|||||||
include 'util', 'dexlib2', 'baksmali', 'smali', 'dexlib2:accessorTestGenerator'
|
include 'util', 'dexlib2', 'baksmali', 'smali', 'dexlib2:accessorTestGenerator'
|
||||||
|
|
||||||
if (System.getProperty("user.dir").startsWith(file("smalidea").absolutePath)) {
|
|
||||||
include 'smalidea'
|
|
||||||
}
|
|
3
smalidea/.gitignore
vendored
3
smalidea/.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
build
|
|
||||||
test-config
|
|
||||||
test-system
|
|
@ -1,235 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url "https://plugins.gradle.org/m2/"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url 'http://dl.bintray.com/jetbrains/intellij-plugin-service'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "gradle.plugin.org.jetbrains:gradle-intellij-plugin:0.1.10"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'idea'
|
|
||||||
apply plugin: 'antlr'
|
|
||||||
|
|
||||||
|
|
||||||
version = '0.05'
|
|
||||||
|
|
||||||
if (!('release' in gradle.startParameter.taskNames)) {
|
|
||||||
def versionSuffix
|
|
||||||
try {
|
|
||||||
def git = org.eclipse.jgit.api.Git.open(file('..'))
|
|
||||||
def head = git.getRepository().getRef('HEAD')
|
|
||||||
versionSuffix = head.getObjectId().abbreviate(8).name()
|
|
||||||
|
|
||||||
if (!git.status().call().clean) {
|
|
||||||
versionSuffix += '-dirty'
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// In case we can't get the commit for some reason,
|
|
||||||
// just use -dev
|
|
||||||
versionSuffix = 'dev'
|
|
||||||
}
|
|
||||||
|
|
||||||
def baseVersion = version
|
|
||||||
version = baseVersion + '-' + versionSuffix
|
|
||||||
} else {
|
|
||||||
if (System.env.JDK7_HOME == null && !JavaVersion.current().isJava7()) {
|
|
||||||
throw new InvalidUserDataException("bzzzzzzzt. Release builds must be performed with java 7. " +
|
|
||||||
"Either run gradle with java 7, or define the JDK7_HOME environment variable.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.env.JDK7_HOME != null) {
|
|
||||||
sourceCompatibility = 1.7
|
|
||||||
targetCompatibility = 1.7
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
doFirst {
|
|
||||||
options.fork = true
|
|
||||||
options.bootClasspath = "$System.env.JDK7_HOME/jre/lib/rt.jar"
|
|
||||||
options.bootClasspath += "$File.pathSeparator$System.env.JDK7_HOME/jre/lib/jsse.jar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def sandboxDir = "${buildDir}/sandbox"
|
|
||||||
|
|
||||||
if (!('idea' in gradle.startParameter.taskNames)) {
|
|
||||||
|
|
||||||
apply plugin: 'org.jetbrains.intellij'
|
|
||||||
|
|
||||||
intellij {
|
|
||||||
version 'IC-2016.3.5'
|
|
||||||
pluginName 'smalidea'
|
|
||||||
|
|
||||||
updateSinceUntilBuild false
|
|
||||||
|
|
||||||
sandboxDirectory sandboxDir
|
|
||||||
}
|
|
||||||
|
|
||||||
// This prints out the directories that can be used to configure a plugin sdk in IDEA, using
|
|
||||||
// the copy of IDEA downloaded by the org.jetbrains.intellij plugin
|
|
||||||
task ideaDirs() {
|
|
||||||
project.afterEvaluate {
|
|
||||||
if (intellij != null) {
|
|
||||||
println "IDEA Plugin jdk: ${intellij.ideaDependency.classes}"
|
|
||||||
println "sources: ${intellij.ideaDependency.getSources()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile files("${System.properties['java.home']}/../lib/tools.jar")
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
project(':') {
|
|
||||||
idea {
|
|
||||||
project {
|
|
||||||
ipr {
|
|
||||||
withXml {
|
|
||||||
def node = it.asNode()
|
|
||||||
|
|
||||||
/*node.find { it.@name == 'ProjectRootManager' }
|
|
||||||
.@'project-jdk-type' = 'IDEA JDK'*/
|
|
||||||
|
|
||||||
def componentNode = node.find { it.@name == 'ProjectRunConfigurationManager' }
|
|
||||||
if (componentNode == null) {
|
|
||||||
componentNode = it.node.appendNode 'component', [name: 'ProjectRunConfigurationManager']
|
|
||||||
}
|
|
||||||
|
|
||||||
if (componentNode.find { it.@name == 'All smalidea tests' } == null) {
|
|
||||||
componentNode.append(new XmlParser().parseText("""
|
|
||||||
<configuration default="false" name="All smalidea tests" type="JUnit" factoryName="JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" runner="idea" />
|
|
||||||
<module name="smalidea" />
|
|
||||||
<option name="TEST_OBJECT" value="directory" />
|
|
||||||
<option name="VM_PARAMETERS" value="-Didea.system.path=${sandboxDir}/config -Didea.system.path=${sandboxDir}/system-test -Didea.load.plugins.id=org.jf.smalidea" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://\$PROJECT_DIR\$/smalidea" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="moduleWithDependencies" />
|
|
||||||
</option>
|
|
||||||
<dir value="\$PROJECT_DIR\$/smalidea/src/test/java" />
|
|
||||||
</configuration>"""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
idea {
|
|
||||||
module {
|
|
||||||
jdkName = 'IDEA Plugin jdk'
|
|
||||||
|
|
||||||
excludeDirs -= buildDir
|
|
||||||
if (buildDir.exists()) {
|
|
||||||
excludeDirs.addAll(buildDir.listFiles())
|
|
||||||
}
|
|
||||||
|
|
||||||
for (sourceDir in (sourceDirs + testSourceDirs)) {
|
|
||||||
excludeDirs.remove(sourceDir);
|
|
||||||
while ((sourceDir = sourceDir.getParentFile()) != null) {
|
|
||||||
excludeDirs.remove(sourceDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iml {
|
|
||||||
withXml {
|
|
||||||
def node = it.node
|
|
||||||
|
|
||||||
node.@type = 'PLUGIN_MODULE'
|
|
||||||
|
|
||||||
def pluginUrl = 'file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml'
|
|
||||||
|
|
||||||
def pluginNode = node.find { it.@name == 'DevKit.ModuleBuildProperties' }
|
|
||||||
if (pluginNode == null) {
|
|
||||||
node.appendNode 'component', [name: 'DevKit.ModuleBuildProperties',
|
|
||||||
url : pluginUrl]
|
|
||||||
} else {
|
|
||||||
pluginNode.@url = pluginUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(':smali')
|
|
||||||
compile depends.antlr_runtime
|
|
||||||
compile depends.gson
|
|
||||||
|
|
||||||
antlr depends.antlr
|
|
||||||
}
|
|
||||||
|
|
||||||
task extractTokens(type: org.gradle.api.tasks.Copy, dependsOn: ':smali:build') {
|
|
||||||
project.afterEvaluate {
|
|
||||||
def allArtifacts = configurations.default.resolvedConfiguration.resolvedArtifacts
|
|
||||||
def smaliArtifact = allArtifacts.find { it.moduleVersion.id.name.equals('smali') }
|
|
||||||
|
|
||||||
from(zipTree(smaliArtifact.file)) {
|
|
||||||
include '**/*.tokens'
|
|
||||||
}
|
|
||||||
into "${buildDir}/tokens"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
generateGrammarSource {
|
|
||||||
def tokensDir = file("${buildDir}/tokens/org/jf/smali")
|
|
||||||
inputs.file new File(tokensDir, 'smaliParser.tokens')
|
|
||||||
setArguments(['-lib', tokensDir.path])
|
|
||||||
outputDirectory(file("${buildDir}/generated-src/antlr/main/org/jf/smalidea"))
|
|
||||||
}
|
|
||||||
generateGrammarSource.dependsOn(extractTokens)
|
|
||||||
ideaModule.dependsOn(generateGrammarSource)
|
|
||||||
|
|
||||||
task release(dependsOn: 'buildPlugin') {
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.getByPath('idea').dependsOn(project(':').getTasksByName('idea', true).findAll({
|
|
||||||
it.project.name != 'smalidea'
|
|
||||||
}))
|
|
File diff suppressed because it is too large
Load Diff
@ -1,166 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lang.PsiBuilder;
|
|
||||||
import com.intellij.lang.PsiBuilder.Marker;
|
|
||||||
import com.intellij.psi.TokenType;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.antlr.runtime.CommonToken;
|
|
||||||
import org.antlr.runtime.Token;
|
|
||||||
import org.antlr.runtime.TokenSource;
|
|
||||||
import org.antlr.runtime.TokenStream;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smali.InvalidToken;
|
|
||||||
import org.jf.smali.smaliParser;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class PsiBuilderTokenStream implements TokenStream {
|
|
||||||
@Nonnull private PsiBuilder psiBuilder;
|
|
||||||
@Nullable private CommonToken currentToken = null;
|
|
||||||
@Nonnull private ArrayList<Marker> markers = new ArrayList<PsiBuilder.Marker>();
|
|
||||||
|
|
||||||
public PsiBuilderTokenStream(@Nonnull PsiBuilder psiBuilder) {
|
|
||||||
this.psiBuilder = psiBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Token LT(int k) {
|
|
||||||
if (k == 1) {
|
|
||||||
if (currentToken == null) {
|
|
||||||
buildCurrentToken();
|
|
||||||
}
|
|
||||||
return currentToken;
|
|
||||||
}
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int range() {
|
|
||||||
return currentToken==null?0:1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Token get(int i) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public TokenSource getTokenSource() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString(int start, int stop) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString(Token start, Token stop) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void consume() {
|
|
||||||
psiBuilder.advanceLexer();
|
|
||||||
buildCurrentToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildCurrentToken() {
|
|
||||||
IElementType element = psiBuilder.getTokenType();
|
|
||||||
if (element != null) {
|
|
||||||
if (element instanceof SmaliLexicalElementType) {
|
|
||||||
SmaliLexicalElementType elementType = (SmaliLexicalElementType)element;
|
|
||||||
currentToken = new CommonToken(elementType.tokenId, psiBuilder.getTokenText());
|
|
||||||
} else if (element == TokenType.BAD_CHARACTER) {
|
|
||||||
currentToken = new InvalidToken("", psiBuilder.getTokenText());
|
|
||||||
} else {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentToken = new CommonToken(Token.EOF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int LA(int i) {
|
|
||||||
IElementType elementType = psiBuilder.lookAhead(i-1);
|
|
||||||
if (elementType == null) {
|
|
||||||
return -1;
|
|
||||||
} else if (elementType instanceof SmaliLexicalElementType) {
|
|
||||||
return ((SmaliLexicalElementType)elementType).tokenId;
|
|
||||||
} else if (elementType == TokenType.BAD_CHARACTER) {
|
|
||||||
return smaliParser.INVALID_TOKEN;
|
|
||||||
}
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int mark() {
|
|
||||||
int ret = markers.size();
|
|
||||||
markers.add(psiBuilder.mark());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int index() {
|
|
||||||
return psiBuilder.getCurrentOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void rewind(int markerIndex) {
|
|
||||||
PsiBuilder.Marker marker = markers.get(markerIndex);
|
|
||||||
marker.rollbackTo();
|
|
||||||
while (markerIndex < markers.size()) {
|
|
||||||
markers.remove(markerIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void rewind() {
|
|
||||||
rewind(markers.size()-1);
|
|
||||||
mark();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void release(int markerIndex) {
|
|
||||||
while (markerIndex < markers.size()) {
|
|
||||||
markers.remove(markerIndex).drop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void seek(int index) {
|
|
||||||
if (index < psiBuilder.getCurrentOffset()) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
while (index > psiBuilder.getCurrentOffset()) {
|
|
||||||
consume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int size() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getSourceName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTFactory;
|
|
||||||
import com.intellij.psi.impl.source.tree.LeafElement;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.leaf.SmaliClassDescriptor;
|
|
||||||
|
|
||||||
public class SmaliASTFactory extends ASTFactory {
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public LeafElement createLeaf(IElementType type, CharSequence text) {
|
|
||||||
if (type == SmaliTokens.CLASS_DESCRIPTOR) {
|
|
||||||
return new SmaliClassDescriptor(text);
|
|
||||||
}
|
|
||||||
return super.createLeaf(type, text);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
|
||||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
|
||||||
import com.intellij.openapi.options.colors.AttributesDescriptor;
|
|
||||||
import com.intellij.openapi.options.colors.ColorDescriptor;
|
|
||||||
import com.intellij.openapi.options.colors.ColorSettingsPage;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SmaliColorsPage implements ColorSettingsPage {
|
|
||||||
private static final AttributesDescriptor[] ATTRS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<TextAttributesKey> keys = SmaliHighlightingColors.getAllKeys();
|
|
||||||
|
|
||||||
ATTRS = new AttributesDescriptor[keys.size()];
|
|
||||||
for (int i=0; i<keys.size(); i++) {
|
|
||||||
TextAttributesKey key = keys.get(i);
|
|
||||||
|
|
||||||
ATTRS[i] = new AttributesDescriptor(key.getExternalName(), key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public Icon getIcon() {
|
|
||||||
return SmaliIcons.SmaliIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public SyntaxHighlighter getHighlighter() {
|
|
||||||
return new SmaliHighlighter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getDemoText() {
|
|
||||||
return ".class public Lorg/jf/smalidea/ColorExample;\n" +
|
|
||||||
".super Ljava/lang/Object;\n" +
|
|
||||||
".source \"ColorExample.smali\"\n" +
|
|
||||||
"\n" +
|
|
||||||
".field public exampleField:I = 1234\n" +
|
|
||||||
"\n" +
|
|
||||||
".field public boolField:Z = true\n" +
|
|
||||||
"\n" +
|
|
||||||
"# This is an example comment\n" +
|
|
||||||
"\n" +
|
|
||||||
".method public constructor <init>()V\n" +
|
|
||||||
" .registers 1\n" +
|
|
||||||
" invoke-direct {p0}, Ljava/lang/Object;-><init>()V\n" +
|
|
||||||
" return-void\n" +
|
|
||||||
".end method\n" +
|
|
||||||
"\n" +
|
|
||||||
".method public exampleMethod()V\n" +
|
|
||||||
" .registers 10\n" +
|
|
||||||
"\n" +
|
|
||||||
" const v0, 1234\n" +
|
|
||||||
" const-string v1, \"An Example String\"\n" +
|
|
||||||
"\n" +
|
|
||||||
" invoke-virtual {p0, v0, v1}, Lorg/jf/smalidea/ColorExample;->anotherMethod(ILjava/lang/String;)V\n" +
|
|
||||||
"\n" +
|
|
||||||
" move v2, v1\n" +
|
|
||||||
" move v1, v0\n" +
|
|
||||||
" move v0, p0\n" +
|
|
||||||
"\n" +
|
|
||||||
" invoke-virtual/range {v0 .. v2}, Lorg/jf/smalidea/ColorExample;->anotherMethod(ILjava/lang/String;)V\n" +
|
|
||||||
"\n" +
|
|
||||||
" return-void\n" +
|
|
||||||
".end method\n" +
|
|
||||||
"\n" +
|
|
||||||
".method public anotherMethod(ILjava/Lang/String;)V\n" +
|
|
||||||
" .registers 10\n" +
|
|
||||||
"\n" +
|
|
||||||
" # This is another example comment\n" +
|
|
||||||
"\n" +
|
|
||||||
" return-void\n" +
|
|
||||||
".end method\n" +
|
|
||||||
"\n" +
|
|
||||||
".method public odexInstructions()V\n" +
|
|
||||||
" .registers 10\n" +
|
|
||||||
" invoke-virtual {p0}, vtable@0x1b\n" +
|
|
||||||
"\n" +
|
|
||||||
" iget-quick p0, field@0x1\n" +
|
|
||||||
"\n" +
|
|
||||||
" execute-inline {p0}, inline@0xa\n" +
|
|
||||||
"\n" +
|
|
||||||
" throw-verification-error illegal-method-access, Lblah;->Blort()V\n" +
|
|
||||||
".end method";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public AttributesDescriptor[] getAttributeDescriptors() {
|
|
||||||
return ATTRS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public ColorDescriptor[] getColorDescriptors() {
|
|
||||||
return ColorDescriptor.EMPTY_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getDisplayName() {
|
|
||||||
return "smali";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class SmaliFileType extends LanguageFileType {
|
|
||||||
public static final SmaliFileType INSTANCE = new SmaliFileType();
|
|
||||||
public static final String DEFAULT_EXTENSION = "smali";
|
|
||||||
|
|
||||||
private SmaliFileType() {
|
|
||||||
super(SmaliLanguage.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getName() {
|
|
||||||
return "smali";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getDescription() {
|
|
||||||
return "smali Files";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getDefaultExtension() {
|
|
||||||
return DEFAULT_EXTENSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Icon getIcon() {
|
|
||||||
return SmaliIcons.SmaliIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isJVMDebuggingSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.FileTypeConsumer;
|
|
||||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SmaliFileTypeFactory extends FileTypeFactory {
|
|
||||||
@Override
|
|
||||||
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
|
|
||||||
consumer.consume(SmaliFileType.INSTANCE, SmaliFileType.DEFAULT_EXTENSION);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lexer.Lexer;
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
|
||||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
|
||||||
public class SmaliHighlighter extends SyntaxHighlighterBase {
|
|
||||||
@NotNull @Override public Lexer getHighlightingLexer() {
|
|
||||||
return new SmaliLexer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
|
|
||||||
if (tokenType instanceof SmaliLexicalElementType) {
|
|
||||||
return ((SmaliLexicalElementType) tokenType).textAttributesKeys;
|
|
||||||
}
|
|
||||||
return new TextAttributesKey[] {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement context sensitive highlighting. i.e. instance fields vs static fields, labels, etc. See: HighlightVisitorImpl
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmaliHighlightingColors {
|
|
||||||
private static final List<TextAttributesKey> allKeys = Lists.newArrayList();
|
|
||||||
|
|
||||||
public static final TextAttributesKey ACCESS = createTextAttributesKey(
|
|
||||||
"ACCESS", DefaultLanguageHighlighterColors.KEYWORD);
|
|
||||||
public static final TextAttributesKey ARROW = createTextAttributesKey(
|
|
||||||
"ARROW", DefaultLanguageHighlighterColors.PREDEFINED_SYMBOL);
|
|
||||||
public static final TextAttributesKey BRACES = createTextAttributesKey(
|
|
||||||
"BRACES", DefaultLanguageHighlighterColors.BRACES);
|
|
||||||
public static final TextAttributesKey COLON = createTextAttributesKey(
|
|
||||||
"COLON", DefaultLanguageHighlighterColors.PREDEFINED_SYMBOL);
|
|
||||||
public static final TextAttributesKey COMMA = createTextAttributesKey(
|
|
||||||
"COMMA", DefaultLanguageHighlighterColors.COMMA);
|
|
||||||
public static final TextAttributesKey COMMENT = createTextAttributesKey(
|
|
||||||
"COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
|
|
||||||
public static final TextAttributesKey DIRECTIVE = createTextAttributesKey(
|
|
||||||
"DIRECTIVE", DefaultLanguageHighlighterColors.KEYWORD);
|
|
||||||
public static final TextAttributesKey DOTDOT = createTextAttributesKey(
|
|
||||||
"DOTDOT", DefaultLanguageHighlighterColors.PREDEFINED_SYMBOL);
|
|
||||||
public static final TextAttributesKey EQUAL = createTextAttributesKey(
|
|
||||||
"EQUAL", DefaultLanguageHighlighterColors.PREDEFINED_SYMBOL);
|
|
||||||
public static final TextAttributesKey IDENTIFIER = createTextAttributesKey(
|
|
||||||
"IDENTIFIER", DefaultLanguageHighlighterColors.INSTANCE_METHOD);
|
|
||||||
public static final TextAttributesKey INSTRUCTION = createTextAttributesKey(
|
|
||||||
"INSTRUCTION", DefaultLanguageHighlighterColors.KEYWORD);
|
|
||||||
public static final TextAttributesKey LITERAL = createTextAttributesKey(
|
|
||||||
"LITERAL", DefaultLanguageHighlighterColors.NUMBER);
|
|
||||||
public static final TextAttributesKey NUMBER = createTextAttributesKey(
|
|
||||||
"NUMBER", DefaultLanguageHighlighterColors.NUMBER);
|
|
||||||
public static final TextAttributesKey ODEX_REFERENCE = createTextAttributesKey(
|
|
||||||
"ODEX_REFERENCE", DefaultLanguageHighlighterColors.INSTANCE_METHOD);
|
|
||||||
public static final TextAttributesKey PARENS = createTextAttributesKey(
|
|
||||||
"PARENS", DefaultLanguageHighlighterColors.PARENTHESES);
|
|
||||||
public static final TextAttributesKey REGISTER = createTextAttributesKey(
|
|
||||||
"REGISTER", DefaultLanguageHighlighterColors.LOCAL_VARIABLE);
|
|
||||||
public static final TextAttributesKey STRING = createTextAttributesKey(
|
|
||||||
"STRING", DefaultLanguageHighlighterColors.STRING);
|
|
||||||
public static final TextAttributesKey TYPE = createTextAttributesKey(
|
|
||||||
"TYPE", DefaultLanguageHighlighterColors.CLASS_REFERENCE);
|
|
||||||
public static final TextAttributesKey VERIFICATION_ERROR_TYPE = createTextAttributesKey(
|
|
||||||
"VERIFICATION_ERROR_TYPE", DefaultLanguageHighlighterColors.KEYWORD);
|
|
||||||
|
|
||||||
private static TextAttributesKey createTextAttributesKey(String name, TextAttributesKey defaultColor) {
|
|
||||||
TextAttributesKey key = TextAttributesKey.createTextAttributesKey(name, defaultColor);
|
|
||||||
allKeys.add(key);
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<TextAttributesKey> getAllKeys() {
|
|
||||||
return Collections.unmodifiableList(allKeys);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.IconLoader;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class SmaliIcons {
|
|
||||||
public static final Icon SmaliIcon = IconLoader.getIcon("/icons/smali.png");
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lang.Language;
|
|
||||||
|
|
||||||
public class SmaliLanguage extends Language {
|
|
||||||
public static final SmaliLanguage INSTANCE = new SmaliLanguage();
|
|
||||||
|
|
||||||
private SmaliLanguage() {
|
|
||||||
super("smali", "text/smali");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isCaseSensitive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lexer.LexerBase;
|
|
||||||
import com.intellij.psi.TokenType;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.antlr.runtime.CommonToken;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smali.smaliFlexLexer;
|
|
||||||
import org.jf.smali.smaliParser;
|
|
||||||
import org.jf.smali.util.BlankReader;
|
|
||||||
|
|
||||||
public class SmaliLexer extends LexerBase {
|
|
||||||
private final smaliFlexLexer lexer = new smaliFlexLexer(BlankReader.INSTANCE);
|
|
||||||
private CommonToken token = null;
|
|
||||||
private int state = 0;
|
|
||||||
private int endOffset;
|
|
||||||
private CharSequence text;
|
|
||||||
|
|
||||||
public SmaliLexer() {
|
|
||||||
super();
|
|
||||||
lexer.setSuppressErrors(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
|
|
||||||
text = buffer;
|
|
||||||
lexer.reset(buffer, startOffset, endOffset, initialState);
|
|
||||||
this.endOffset = endOffset;
|
|
||||||
this.token = null;
|
|
||||||
this.state = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public CharSequence getTokenSequence() {
|
|
||||||
return getTokenText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getTokenText() {
|
|
||||||
ensureToken();
|
|
||||||
return token.getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getState() {
|
|
||||||
ensureToken();
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IElementType getTokenType() {
|
|
||||||
ensureToken();
|
|
||||||
return mapTokenTypeToElementType(token.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
private IElementType mapTokenTypeToElementType(int tokenType) {
|
|
||||||
if (tokenType == smaliParser.WHITE_SPACE) {
|
|
||||||
return TokenType.WHITE_SPACE;
|
|
||||||
}
|
|
||||||
if (tokenType == smaliParser.INVALID_TOKEN) {
|
|
||||||
return TokenType.BAD_CHARACTER;
|
|
||||||
}
|
|
||||||
if (tokenType == smaliParser.EOF) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return SmaliTokens.getElementType(tokenType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTokenStart() {
|
|
||||||
ensureToken();
|
|
||||||
return token.getStartIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTokenEnd() {
|
|
||||||
ensureToken();
|
|
||||||
return token.getStopIndex()+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void advance() {
|
|
||||||
token = null;
|
|
||||||
state = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public CharSequence getBufferSequence() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBufferEnd() {
|
|
||||||
return endOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureToken() {
|
|
||||||
if (token == null) {
|
|
||||||
token = (CommonToken)lexer.nextToken();
|
|
||||||
state = lexer.yystate();
|
|
||||||
}
|
|
||||||
assert token != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
|
|
||||||
public class SmaliLexicalElementType extends IElementType {
|
|
||||||
public final int tokenId;
|
|
||||||
public final TextAttributesKey[] textAttributesKeys;
|
|
||||||
|
|
||||||
protected SmaliLexicalElementType(int tokenId, String tokenName, TextAttributesKey textAttributesKey) {
|
|
||||||
super(tokenName, SmaliLanguage.INSTANCE);
|
|
||||||
this.tokenId = tokenId;
|
|
||||||
this.textAttributesKeys = new TextAttributesKey[] {textAttributesKey};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.lang.PsiBuilder;
|
|
||||||
import com.intellij.lang.PsiParser;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.antlr.runtime.RecognitionException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliParser implements PsiParser {
|
|
||||||
@NotNull @Override public ASTNode parse(IElementType root, PsiBuilder builder) {
|
|
||||||
builder.setDebugMode(true);
|
|
||||||
|
|
||||||
PsiBuilder.Marker rootMarker = builder.mark();
|
|
||||||
PsiBuilder.Marker classMarker = builder.mark();
|
|
||||||
|
|
||||||
PsiBuilderTokenStream tokenStream = new PsiBuilderTokenStream(builder);
|
|
||||||
smalideaParser parser = new smalideaParser(tokenStream);
|
|
||||||
parser.setPsiBuilder(builder);
|
|
||||||
try {
|
|
||||||
parser.smali_file();
|
|
||||||
} catch (RecognitionException ex) {
|
|
||||||
// TODO: how to handle this?
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
classMarker.done(SmaliElementTypes.CLASS);
|
|
||||||
rootMarker.done(root);
|
|
||||||
return builder.getTreeBuilt();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.lang.LanguageUtil;
|
|
||||||
import com.intellij.lang.ParserDefinition;
|
|
||||||
import com.intellij.lang.PsiParser;
|
|
||||||
import com.intellij.lexer.Lexer;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.psi.FileViewProvider;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiFile;
|
|
||||||
import com.intellij.psi.TokenType;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import com.intellij.psi.tree.IFileElementType;
|
|
||||||
import com.intellij.psi.tree.TokenSet;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliFile;
|
|
||||||
import org.jf.smalidea.psi.stub.element.SmaliStubElementType;
|
|
||||||
|
|
||||||
public class SmaliParserDefinition implements ParserDefinition {
|
|
||||||
@NotNull @Override public Lexer createLexer(Project project) {
|
|
||||||
return new SmaliLexer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiParser createParser(Project project) {
|
|
||||||
return new SmaliParser();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public IFileElementType getFileNodeType() {
|
|
||||||
return SmaliElementTypes.FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final TokenSet WHITESPACE = TokenSet.create(TokenType.WHITE_SPACE);
|
|
||||||
@NotNull @Override public TokenSet getWhitespaceTokens() {
|
|
||||||
return WHITESPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final TokenSet COMMENT = TokenSet.create(SmaliTokens.LINE_COMMENT);
|
|
||||||
@NotNull @Override public TokenSet getCommentTokens() {
|
|
||||||
return COMMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final TokenSet STRING_LITERAL = TokenSet.create(SmaliTokens.STRING_LITERAL);
|
|
||||||
@NotNull @Override public TokenSet getStringLiteralElements() {
|
|
||||||
return STRING_LITERAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiElement createElement(ASTNode node) {
|
|
||||||
IElementType elementType = node.getElementType();
|
|
||||||
if (elementType instanceof SmaliStubElementType) {
|
|
||||||
return ((SmaliStubElementType)elementType).createPsi(node);
|
|
||||||
}
|
|
||||||
throw new RuntimeException("Unexpected element type");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiFile createFile(FileViewProvider viewProvider) {
|
|
||||||
return new SmaliFile(viewProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
|
|
||||||
return LanguageUtil.canStickTokensTogetherByLexer(left, right, new SmaliLexer());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,363 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import com.intellij.psi.tree.TokenSet;
|
|
||||||
import org.jf.smali.smaliParser;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SmaliTokens {
|
|
||||||
private static final IElementType[] ELEMENT_TYPES;
|
|
||||||
|
|
||||||
public static IElementType getElementType(int tokenType) {
|
|
||||||
return ELEMENT_TYPES[tokenType];
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ACCESS_SPEC;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ANNOTATION_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ANNOTATION_VISIBILITY;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ARRAY_DATA_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ARRAY_TYPE_PREFIX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ARROW;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType BOOL_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType BYTE_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CATCH_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CATCHALL_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CHAR_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CLASS_DESCRIPTOR;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CLASS_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CLOSE_BRACE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType CLOSE_PAREN;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType COLON;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType COMMA;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType DOTDOT;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType DOUBLE_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType DOUBLE_LITERAL_OR_ID;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_ANNOTATION_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_ARRAY_DATA_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_FIELD_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_LOCAL_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_METHOD_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_PACKED_SWITCH_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_PARAMETER_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_SPARSE_SWITCH_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType END_SUBANNOTATION_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType ENUM_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType EPILOGUE_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType EQUAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType FIELD_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType FIELD_OFFSET;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType FLOAT_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType FLOAT_LITERAL_OR_ID;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType IMPLEMENTS_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INLINE_INDEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT10t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT10x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT10x_ODEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT11n;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT11x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT12x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT12x_OR_ID;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT20bc;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT20t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21c_FIELD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21c_FIELD_ODEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21c_STRING;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21c_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21ih;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21lh;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21s;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT21t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22b;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22c_FIELD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22c_FIELD_ODEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22c_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22cs_FIELD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22s;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22s_OR_ID;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT22x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT23x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT30t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT31c;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT31i;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT31i_OR_ID;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT31t;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT32x;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35c_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35c_METHOD_ODEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35c_METHOD_OR_METHOD_HANDLE_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35c_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35mi_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT35ms_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT3rc_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT3rc_METHOD_ODEX;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT3rc_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT3rmi_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT3rms_METHOD;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType INSTRUCTION_FORMAT51l;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType LINE_COMMENT;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType LINE_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType LOCAL_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType LOCALS_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType LONG_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType METHOD_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType MEMBER_NAME;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType NEGATIVE_INTEGER_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType NULL_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType OPEN_BRACE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType OPEN_PAREN;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType PACKED_SWITCH_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType PARAM_LIST_OR_ID_PRIMITIVE_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType PARAMETER_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType POSITIVE_INTEGER_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType PRIMITIVE_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType PROLOGUE_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType REGISTER;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType REGISTERS_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType RESTART_LOCAL_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SHORT_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SIMPLE_NAME;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SOURCE_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SPARSE_SWITCH_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType STRING_LITERAL;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SUBANNOTATION_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType SUPER_DIRECTIVE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType VERIFICATION_ERROR_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType VOID_TYPE;
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"}) public static IElementType VTABLE_INDEX;
|
|
||||||
|
|
||||||
public static final TokenSet INSTRUCTION_TOKENS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
Map<String, TextAttributesKey> tokenColors = Maps.newHashMap();
|
|
||||||
|
|
||||||
tokenColors.put("ACCESS_SPEC", SmaliHighlightingColors.ACCESS);
|
|
||||||
tokenColors.put("ANNOTATION_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("ANNOTATION_VISIBILITY", SmaliHighlightingColors.ACCESS);
|
|
||||||
tokenColors.put("ARRAY_DATA_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("ARRAY_TYPE_PREFIX", SmaliHighlightingColors.TYPE);
|
|
||||||
tokenColors.put("ARROW", SmaliHighlightingColors.ARROW);
|
|
||||||
tokenColors.put("BOOL_LITERAL", SmaliHighlightingColors.LITERAL);
|
|
||||||
tokenColors.put("BYTE_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("CATCH_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("CATCHALL_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("CHAR_LITERAL", SmaliHighlightingColors.STRING);
|
|
||||||
tokenColors.put("CLASS_DESCRIPTOR", SmaliHighlightingColors.TYPE);
|
|
||||||
tokenColors.put("CLASS_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("CLOSE_BRACE", SmaliHighlightingColors.BRACES);
|
|
||||||
tokenColors.put("CLOSE_PAREN", SmaliHighlightingColors.PARENS);
|
|
||||||
tokenColors.put("COLON", SmaliHighlightingColors.COLON);
|
|
||||||
tokenColors.put("COMMA", SmaliHighlightingColors.COMMA);
|
|
||||||
tokenColors.put("DOTDOT", SmaliHighlightingColors.DOTDOT);
|
|
||||||
tokenColors.put("DOUBLE_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("DOUBLE_LITERAL_OR_ID", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("END_ANNOTATION_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_ARRAY_DATA_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_FIELD_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_LOCAL_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_METHOD_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_PACKED_SWITCH_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_PARAMETER_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_SPARSE_SWITCH_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("END_SUBANNOTATION_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("ENUM_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("EPILOGUE_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("EQUAL", SmaliHighlightingColors.EQUAL);
|
|
||||||
tokenColors.put("FIELD_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("FIELD_OFFSET", SmaliHighlightingColors.ODEX_REFERENCE);
|
|
||||||
tokenColors.put("FLOAT_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("FLOAT_LITERAL_OR_ID", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("IMPLEMENTS_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("INLINE_INDEX", SmaliHighlightingColors.ODEX_REFERENCE);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT10t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT10x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT10x_ODEX", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT11n", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT11x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT12x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT12x_OR_ID", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT20bc", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT20t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21c_FIELD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21c_FIELD_ODEX", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21c_STRING", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21c_TYPE", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21ih", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21lh", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21s", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT21t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22b", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22c_FIELD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22c_FIELD_ODEX", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22c_TYPE", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22cs_FIELD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22s", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22s_OR_ID", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT22x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT23x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT30t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT31c", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT31i", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT31i_OR_ID", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT31t", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT32x", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35c_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35c_METHOD_ODEX", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35c_METHOD_OR_METHOD_HANDLE_TYPE", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35c_TYPE", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35mi_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT35ms_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT3rc_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT3rc_METHOD_ODEX", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT3rc_TYPE", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT3rmi_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT3rms_METHOD", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("INSTRUCTION_FORMAT51l", SmaliHighlightingColors.INSTRUCTION);
|
|
||||||
tokenColors.put("LINE_COMMENT", SmaliHighlightingColors.COMMENT);
|
|
||||||
tokenColors.put("LINE_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("LOCAL_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("LOCALS_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("LONG_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("MEMBER_NAME", SmaliHighlightingColors.IDENTIFIER);
|
|
||||||
tokenColors.put("METHOD_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("NEGATIVE_INTEGER_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("NULL_LITERAL", SmaliHighlightingColors.LITERAL);
|
|
||||||
tokenColors.put("OPEN_BRACE", SmaliHighlightingColors.BRACES);
|
|
||||||
tokenColors.put("OPEN_PAREN", SmaliHighlightingColors.PARENS);
|
|
||||||
tokenColors.put("PACKED_SWITCH_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("PARAM_LIST_OR_ID_PRIMITIVE_TYPE", SmaliHighlightingColors.TYPE);
|
|
||||||
tokenColors.put("PARAMETER_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("POSITIVE_INTEGER_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("PRIMITIVE_TYPE", SmaliHighlightingColors.TYPE);
|
|
||||||
tokenColors.put("PROLOGUE_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("REGISTER", SmaliHighlightingColors.REGISTER);
|
|
||||||
tokenColors.put("REGISTERS_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("RESTART_LOCAL_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("SHORT_LITERAL", SmaliHighlightingColors.NUMBER);
|
|
||||||
tokenColors.put("SIMPLE_NAME", SmaliHighlightingColors.IDENTIFIER);
|
|
||||||
tokenColors.put("SOURCE_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("SPARSE_SWITCH_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("STRING_LITERAL", SmaliHighlightingColors.STRING);
|
|
||||||
tokenColors.put("SUBANNOTATION_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("SUPER_DIRECTIVE", SmaliHighlightingColors.DIRECTIVE);
|
|
||||||
tokenColors.put("VERIFICATION_ERROR_TYPE", SmaliHighlightingColors.VERIFICATION_ERROR_TYPE);
|
|
||||||
tokenColors.put("VOID_TYPE", SmaliHighlightingColors.TYPE);
|
|
||||||
tokenColors.put("VTABLE_INDEX", SmaliHighlightingColors.ODEX_REFERENCE);
|
|
||||||
|
|
||||||
int tokenCount = smaliParser.tokenNames.length;
|
|
||||||
ELEMENT_TYPES = new IElementType[tokenCount];
|
|
||||||
|
|
||||||
for (int tokenId=0; tokenId<tokenCount; tokenId++) {
|
|
||||||
String tokenName = smaliParser.tokenNames[tokenId];
|
|
||||||
Field field;
|
|
||||||
|
|
||||||
try {
|
|
||||||
field = SmaliTokens.class.getField(tokenName);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextAttributesKey textAttributesKey = tokenColors.get(tokenName);
|
|
||||||
|
|
||||||
if (textAttributesKey == null) {
|
|
||||||
throw new RuntimeException("No color attribute for token " + tokenName);
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliLexicalElementType elementType = new SmaliLexicalElementType(tokenId, tokenName, textAttributesKey);
|
|
||||||
ELEMENT_TYPES[tokenId] = elementType;
|
|
||||||
|
|
||||||
try {
|
|
||||||
field.set(null, elementType);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
INSTRUCTION_TOKENS = TokenSet.create(
|
|
||||||
INSTRUCTION_FORMAT10t,
|
|
||||||
INSTRUCTION_FORMAT10x,
|
|
||||||
INSTRUCTION_FORMAT10x_ODEX,
|
|
||||||
INSTRUCTION_FORMAT11n,
|
|
||||||
INSTRUCTION_FORMAT11x,
|
|
||||||
INSTRUCTION_FORMAT12x_OR_ID,
|
|
||||||
INSTRUCTION_FORMAT12x,
|
|
||||||
INSTRUCTION_FORMAT20bc,
|
|
||||||
INSTRUCTION_FORMAT20t,
|
|
||||||
INSTRUCTION_FORMAT21c_FIELD,
|
|
||||||
INSTRUCTION_FORMAT21c_FIELD_ODEX,
|
|
||||||
INSTRUCTION_FORMAT21c_STRING,
|
|
||||||
INSTRUCTION_FORMAT21c_TYPE,
|
|
||||||
INSTRUCTION_FORMAT21ih,
|
|
||||||
INSTRUCTION_FORMAT21lh,
|
|
||||||
INSTRUCTION_FORMAT21s,
|
|
||||||
INSTRUCTION_FORMAT21t,
|
|
||||||
INSTRUCTION_FORMAT22b,
|
|
||||||
INSTRUCTION_FORMAT22c_FIELD,
|
|
||||||
INSTRUCTION_FORMAT22c_FIELD_ODEX,
|
|
||||||
INSTRUCTION_FORMAT22c_TYPE,
|
|
||||||
INSTRUCTION_FORMAT22cs_FIELD,
|
|
||||||
INSTRUCTION_FORMAT22s_OR_ID,
|
|
||||||
INSTRUCTION_FORMAT22s,
|
|
||||||
INSTRUCTION_FORMAT22t,
|
|
||||||
INSTRUCTION_FORMAT22x,
|
|
||||||
INSTRUCTION_FORMAT23x,
|
|
||||||
INSTRUCTION_FORMAT30t,
|
|
||||||
INSTRUCTION_FORMAT31c,
|
|
||||||
INSTRUCTION_FORMAT31i_OR_ID,
|
|
||||||
INSTRUCTION_FORMAT31i,
|
|
||||||
INSTRUCTION_FORMAT31t,
|
|
||||||
INSTRUCTION_FORMAT32x,
|
|
||||||
INSTRUCTION_FORMAT35c_METHOD,
|
|
||||||
INSTRUCTION_FORMAT35c_METHOD_ODEX,
|
|
||||||
INSTRUCTION_FORMAT35c_METHOD_OR_METHOD_HANDLE_TYPE,
|
|
||||||
INSTRUCTION_FORMAT35c_TYPE,
|
|
||||||
INSTRUCTION_FORMAT35mi_METHOD,
|
|
||||||
INSTRUCTION_FORMAT35ms_METHOD,
|
|
||||||
INSTRUCTION_FORMAT3rc_METHOD,
|
|
||||||
INSTRUCTION_FORMAT3rc_METHOD_ODEX,
|
|
||||||
INSTRUCTION_FORMAT3rc_TYPE,
|
|
||||||
INSTRUCTION_FORMAT3rmi_METHOD,
|
|
||||||
INSTRUCTION_FORMAT3rms_METHOD,
|
|
||||||
INSTRUCTION_FORMAT51l,
|
|
||||||
ARRAY_DATA_DIRECTIVE,
|
|
||||||
PACKED_SWITCH_DIRECTIVE,
|
|
||||||
SPARSE_SWITCH_DIRECTIVE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,393 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.intellij.debugger.SourcePosition;
|
|
||||||
import com.intellij.debugger.engine.evaluation.*;
|
|
||||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
|
|
||||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
|
||||||
import com.intellij.debugger.engine.jdi.StackFrameProxy;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.openapi.util.Key;
|
|
||||||
import com.intellij.psi.JavaCodeFragment;
|
|
||||||
import com.intellij.psi.JavaRecursiveElementVisitor;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiLocalVariable;
|
|
||||||
import com.intellij.psi.util.PsiMatchers;
|
|
||||||
import com.sun.jdi.*;
|
|
||||||
import com.sun.tools.jdi.LocalVariableImpl;
|
|
||||||
import com.sun.tools.jdi.LocationImpl;
|
|
||||||
import org.jf.dexlib2.analysis.AnalyzedInstruction;
|
|
||||||
import org.jf.dexlib2.analysis.RegisterType;
|
|
||||||
import org.jf.smalidea.SmaliFileType;
|
|
||||||
import org.jf.smalidea.SmaliLanguage;
|
|
||||||
import org.jf.smalidea.debugging.value.LazyValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
import org.jf.smalidea.util.PsiUtil;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SmaliCodeFragmentFactory extends DefaultCodeFragmentFactory {
|
|
||||||
static final Key<List<LazyValue>> SMALI_LAZY_VALUES_KEY = Key.create("_smali_register_value_key_");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, Project project) {
|
|
||||||
context = wrapContext(project, context);
|
|
||||||
JavaCodeFragment fragment = super.createCodeFragment(item, context, project);
|
|
||||||
List<LazyValue> lazyValues = context.getUserData(SMALI_LAZY_VALUES_KEY);
|
|
||||||
if (lazyValues != null) {
|
|
||||||
fragment.putUserData(SMALI_LAZY_VALUES_KEY, lazyValues);
|
|
||||||
}
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isContextAccepted(PsiElement contextElement) {
|
|
||||||
if (contextElement == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return contextElement.getLanguage() == SmaliLanguage.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaCodeFragment createPresentationCodeFragment(TextWithImports item, PsiElement context, Project project) {
|
|
||||||
context = wrapContext(project, context);
|
|
||||||
JavaCodeFragment fragment = super.createPresentationCodeFragment(item, context, project);
|
|
||||||
List<LazyValue> lazyValues = context.getUserData(SMALI_LAZY_VALUES_KEY);
|
|
||||||
if (lazyValues != null) {
|
|
||||||
fragment.putUserData(SMALI_LAZY_VALUES_KEY, lazyValues);
|
|
||||||
}
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public LanguageFileType getFileType() {
|
|
||||||
return SmaliFileType.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public EvaluatorBuilder getEvaluatorBuilder() {
|
|
||||||
final EvaluatorBuilder builder = super.getEvaluatorBuilder();
|
|
||||||
return new EvaluatorBuilder() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExpressionEvaluator build(PsiElement codeFragment, SourcePosition position)
|
|
||||||
throws EvaluateException {
|
|
||||||
return new SmaliExpressionEvaluator(codeFragment, builder.build(codeFragment, position));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private PsiElement wrapContext(final Project project, final PsiElement originalContext) {
|
|
||||||
if (project.isDefault()) return originalContext;
|
|
||||||
|
|
||||||
final List<LazyValue> lazyValues = Lists.newArrayList();
|
|
||||||
|
|
||||||
SmaliInstruction currentInstruction = (SmaliInstruction)PsiUtil.searchBackward(originalContext,
|
|
||||||
PsiMatchers.hasClass(SmaliInstruction.class),
|
|
||||||
PsiMatchers.hasClass(SmaliMethod.class));
|
|
||||||
|
|
||||||
if (currentInstruction == null) {
|
|
||||||
currentInstruction = (SmaliInstruction)PsiUtil.searchForward(originalContext,
|
|
||||||
PsiMatchers.hasClass(SmaliInstruction.class),
|
|
||||||
PsiMatchers.hasClass(SmaliMethod.class));
|
|
||||||
if (currentInstruction == null) {
|
|
||||||
return originalContext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final SmaliMethod containingMethod = currentInstruction.getParentMethod();
|
|
||||||
AnalyzedInstruction analyzedInstruction = currentInstruction.getAnalyzedInstruction();
|
|
||||||
if (analyzedInstruction == null) {
|
|
||||||
return originalContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int firstParameterRegister = containingMethod.getRegisterCount() -
|
|
||||||
containingMethod.getParameterRegisterCount();
|
|
||||||
|
|
||||||
final Map<String, String> registerMap = Maps.newHashMap();
|
|
||||||
StringBuilder variablesText = new StringBuilder();
|
|
||||||
for (int i=0; i<containingMethod.getRegisterCount(); i++) {
|
|
||||||
int parameterRegisterNumber = i - firstParameterRegister;
|
|
||||||
|
|
||||||
RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(i);
|
|
||||||
switch (registerType.category) {
|
|
||||||
case RegisterType.UNKNOWN:
|
|
||||||
case RegisterType.UNINIT:
|
|
||||||
case RegisterType.CONFLICTED:
|
|
||||||
case RegisterType.LONG_HI:
|
|
||||||
case RegisterType.DOUBLE_HI:
|
|
||||||
continue;
|
|
||||||
case RegisterType.NULL:
|
|
||||||
case RegisterType.ONE:
|
|
||||||
case RegisterType.INTEGER:
|
|
||||||
variablesText.append("int v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "I");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("int p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "I");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.BOOLEAN:
|
|
||||||
variablesText.append("boolean v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "Z");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("boolean p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "Z");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.BYTE:
|
|
||||||
case RegisterType.POS_BYTE:
|
|
||||||
variablesText.append("byte v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "B");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("byte p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "B");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.SHORT:
|
|
||||||
case RegisterType.POS_SHORT:
|
|
||||||
variablesText.append("short v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "S");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("short p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "S");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.CHAR:
|
|
||||||
variablesText.append("char v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "C");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("char p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "C");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.FLOAT:
|
|
||||||
variablesText.append("float v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "F");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("float p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "F");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.LONG_LO:
|
|
||||||
variablesText.append("long v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "J");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("long p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "J");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.DOUBLE_LO:
|
|
||||||
variablesText.append("double v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, "D");
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append("double p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "D");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RegisterType.UNINIT_REF:
|
|
||||||
case RegisterType.UNINIT_THIS:
|
|
||||||
case RegisterType.REFERENCE:
|
|
||||||
String smaliType = registerType.type.getType();
|
|
||||||
String javaType = NameUtils.smaliToJavaType(smaliType);
|
|
||||||
variablesText.append(javaType).append(" v").append(i).append(";\n");
|
|
||||||
registerMap.put("v" + i, smaliType);
|
|
||||||
if (parameterRegisterNumber >= 0) {
|
|
||||||
variablesText.append(javaType).append(" p").append(parameterRegisterNumber).append(";\n");
|
|
||||||
registerMap.put("p" + parameterRegisterNumber, "Ljava/lang/Object;");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.CODE_BLOCK,
|
|
||||||
variablesText.toString(), "", getFileType());
|
|
||||||
|
|
||||||
final JavaCodeFragment codeFragment = super.createCodeFragment(textWithImports, originalContext, project);
|
|
||||||
|
|
||||||
codeFragment.accept(new JavaRecursiveElementVisitor() {
|
|
||||||
@Override
|
|
||||||
public void visitLocalVariable(final PsiLocalVariable variable) {
|
|
||||||
final String name = variable.getName();
|
|
||||||
if (name != null && registerMap.containsKey(name)) {
|
|
||||||
int registerNumber = Integer.parseInt(name.substring(1));
|
|
||||||
if (name.charAt(0) == 'p') {
|
|
||||||
registerNumber += ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
|
|
||||||
@Override public Integer compute() {
|
|
||||||
return containingMethod.getRegisterCount() -
|
|
||||||
containingMethod.getParameterRegisterCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
LazyValue lazyValue = LazyValue.create(containingMethod, project, registerNumber,
|
|
||||||
registerMap.get(name));
|
|
||||||
variable.putUserData(CodeFragmentFactoryContextWrapper.LABEL_VARIABLE_VALUE_KEY, lazyValue);
|
|
||||||
lazyValues.add(lazyValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
int offset = variablesText.length() - 1;
|
|
||||||
|
|
||||||
final PsiElement newContext = codeFragment.findElementAt(offset);
|
|
||||||
if (newContext != null) {
|
|
||||||
newContext.putUserData(SMALI_LAZY_VALUES_KEY, lazyValues);
|
|
||||||
return newContext;
|
|
||||||
}
|
|
||||||
return originalContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static Value evaluateRegister(EvaluationContext context, final SmaliMethod smaliMethod,
|
|
||||||
final int registerNum, final String type) throws EvaluateException {
|
|
||||||
|
|
||||||
if (registerNum >= smaliMethod.getRegisterCount()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final StackFrameProxy frameProxy = context.getSuspendContext().getFrameProxy();
|
|
||||||
if (frameProxy == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtualMachine vm = frameProxy.getStackFrame().virtualMachine();
|
|
||||||
Location currentLocation = frameProxy.location();
|
|
||||||
if (currentLocation == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Method method = currentLocation.method();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final Constructor<LocalVariableImpl> localVariableConstructor = LocalVariableImpl.class.getDeclaredConstructor(
|
|
||||||
VirtualMachine.class, Method.class, Integer.TYPE, Location.class, Location.class, String.class,
|
|
||||||
String.class, String.class);
|
|
||||||
localVariableConstructor.setAccessible(true);
|
|
||||||
|
|
||||||
Constructor<LocationImpl> locationConstructor = LocationImpl.class.getDeclaredConstructor(
|
|
||||||
VirtualMachine.class, Method.class, Long.TYPE);
|
|
||||||
locationConstructor.setAccessible(true);
|
|
||||||
|
|
||||||
int methodSize = 0;
|
|
||||||
for (SmaliInstruction instruction: smaliMethod.getInstructions()) {
|
|
||||||
methodSize += instruction.getInstructionSize();
|
|
||||||
}
|
|
||||||
Location endLocation = null;
|
|
||||||
for (int endCodeIndex = (methodSize/2) - 1; endCodeIndex >= 0; endCodeIndex--) {
|
|
||||||
endLocation = method.locationOfCodeIndex(endCodeIndex);
|
|
||||||
if (endLocation != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (endLocation == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalVariable localVariable = localVariableConstructor.newInstance(vm,
|
|
||||||
method,
|
|
||||||
mapRegister(frameProxy.getStackFrame().virtualMachine(), smaliMethod, registerNum),
|
|
||||||
method.location(),
|
|
||||||
endLocation,
|
|
||||||
String.format("v%d", registerNum), type, null);
|
|
||||||
|
|
||||||
return frameProxy.getStackFrame().getValue(localVariable);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
return null;
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
return null;
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
return null;
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int mapRegister(final VirtualMachine vm, final SmaliMethod smaliMethod, final int register) {
|
|
||||||
if (vm.version().equals("1.5.0")) {
|
|
||||||
return mapRegisterForDalvik(smaliMethod, register);
|
|
||||||
} else {
|
|
||||||
return mapRegisterForArt(smaliMethod, register);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int mapRegisterForArt(final SmaliMethod smaliMethod, final int register) {
|
|
||||||
return ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
|
|
||||||
@Override public Integer compute() {
|
|
||||||
|
|
||||||
int totalRegisters = smaliMethod.getRegisterCount();
|
|
||||||
int parameterRegisters = smaliMethod.getParameterRegisterCount();
|
|
||||||
|
|
||||||
if (smaliMethod.getModifierList().hasModifierProperty("static")) {
|
|
||||||
return register;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For ART, the parameter registers are rotated to the front
|
|
||||||
if (register >= (totalRegisters - parameterRegisters)) {
|
|
||||||
return register - (totalRegisters - parameterRegisters);
|
|
||||||
}
|
|
||||||
return register + parameterRegisters;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int mapRegisterForDalvik(final SmaliMethod smaliMethod, final int register) {
|
|
||||||
return ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
|
|
||||||
@Override public Integer compute() {
|
|
||||||
if (smaliMethod.getModifierList().hasModifierProperty("static")) {
|
|
||||||
return register;
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalRegisters = smaliMethod.getRegisterCount();
|
|
||||||
int parameterRegisters = smaliMethod.getParameterRegisterCount();
|
|
||||||
|
|
||||||
// For dalvik, p0 is mapped to register 1, and register 0 is mapped to register 1000
|
|
||||||
if (register == (totalRegisters - parameterRegisters)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (register == 0) {
|
|
||||||
return 1000;
|
|
||||||
}
|
|
||||||
return register;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging;
|
|
||||||
|
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
|
||||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
|
||||||
import com.intellij.debugger.engine.evaluation.expression.Modifier;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.sun.jdi.Value;
|
|
||||||
import org.jf.smalidea.debugging.value.LazyValue;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmaliExpressionEvaluator implements ExpressionEvaluator {
|
|
||||||
private final PsiElement fragment;
|
|
||||||
private final ExpressionEvaluator evaluator;
|
|
||||||
|
|
||||||
public SmaliExpressionEvaluator(PsiElement fragment, ExpressionEvaluator evaluator) {
|
|
||||||
this.fragment = fragment;
|
|
||||||
this.evaluator = evaluator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Value evaluate(EvaluationContext context) throws EvaluateException {
|
|
||||||
List<LazyValue> lazyValues = fragment.getUserData(SmaliCodeFragmentFactory.SMALI_LAZY_VALUES_KEY);
|
|
||||||
if (lazyValues != null) {
|
|
||||||
for (LazyValue lazyValue: lazyValues) {
|
|
||||||
lazyValue.setEvaluationContext(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return evaluator.evaluate(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Value getValue() {
|
|
||||||
return evaluator.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Modifier getModifier() {
|
|
||||||
return evaluator.getModifier();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging;
|
|
||||||
|
|
||||||
import com.intellij.debugger.NoDataException;
|
|
||||||
import com.intellij.debugger.PositionManager;
|
|
||||||
import com.intellij.debugger.SourcePosition;
|
|
||||||
import com.intellij.debugger.engine.DebugProcess;
|
|
||||||
import com.intellij.debugger.requests.ClassPrepareRequestor;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiFile;
|
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
|
||||||
import com.sun.jdi.Location;
|
|
||||||
import com.sun.jdi.ReferenceType;
|
|
||||||
import com.sun.jdi.request.ClassPrepareRequest;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliClass;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliFile;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
import org.jf.smalidea.psi.index.SmaliClassNameIndex;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmaliPositionManager implements PositionManager {
|
|
||||||
private final DebugProcess debugProcess;
|
|
||||||
|
|
||||||
public SmaliPositionManager(DebugProcess debugProcess) {
|
|
||||||
this.debugProcess = debugProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SourcePosition getSourcePosition(final String declaringType, String methodName, String methodSignature,
|
|
||||||
int codeIndex) throws NoDataException {
|
|
||||||
|
|
||||||
Collection<SmaliClass> classes = ApplicationManager.getApplication().runReadAction(
|
|
||||||
new Computable<Collection<SmaliClass>>() {
|
|
||||||
@Override public Collection<SmaliClass> compute() {
|
|
||||||
return SmaliClassNameIndex.INSTANCE.get(declaringType, debugProcess.getProject(),
|
|
||||||
GlobalSearchScope.projectScope(debugProcess.getProject()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (classes.size() > 0) {
|
|
||||||
SmaliClass smaliClass = classes.iterator().next();
|
|
||||||
|
|
||||||
// TODO: make an index for this?
|
|
||||||
for (SmaliMethod smaliMethod: smaliClass.getMethods()) {
|
|
||||||
if (smaliMethod.getName().equals(methodName) &&
|
|
||||||
smaliMethod.getMethodPrototype().getText().equals(methodSignature)) {
|
|
||||||
return smaliMethod.getSourcePositionForCodeOffset(codeIndex * 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw NoDataException.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SourcePosition getSourcePosition(@Nullable Location location) throws NoDataException {
|
|
||||||
if (location == null) {
|
|
||||||
throw NoDataException.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getSourcePosition(location.declaringType().name(), location.method().name(),
|
|
||||||
location.method().signature(), (int)location.codeIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @NotNull
|
|
||||||
public List<ReferenceType> getAllClasses(@NotNull SourcePosition classPosition) throws NoDataException {
|
|
||||||
if (!(classPosition.getElementAt().getContainingFile() instanceof SmaliFile)) {
|
|
||||||
throw NoDataException.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
String className = getClassFromPosition(classPosition);
|
|
||||||
return debugProcess.getVirtualMachineProxy().classesByName(className);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String getClassFromPosition(@NotNull final SourcePosition position) {
|
|
||||||
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
|
||||||
@Override public String compute() {
|
|
||||||
SmaliClass smaliClass = ((SmaliFile)position.getElementAt().getContainingFile()).getPsiClass();
|
|
||||||
if (smaliClass == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return smaliClass.getQualifiedName();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @NotNull
|
|
||||||
public List<Location> locationsOfLine(@NotNull final ReferenceType type,
|
|
||||||
@NotNull final SourcePosition position) throws NoDataException {
|
|
||||||
PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
|
|
||||||
@Override public PsiFile compute() {
|
|
||||||
return position.getElementAt().getContainingFile();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!(containingFile instanceof SmaliFile)) {
|
|
||||||
throw NoDataException.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ArrayList<Location> locations = new ArrayList<Location>(1);
|
|
||||||
|
|
||||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
|
|
||||||
String typeName = type.name();
|
|
||||||
Collection<SmaliClass> classes = SmaliClassNameIndex.INSTANCE.get(typeName, debugProcess.getProject(),
|
|
||||||
GlobalSearchScope.projectScope(debugProcess.getProject()));
|
|
||||||
|
|
||||||
if (classes.size() > 0) {
|
|
||||||
final SmaliClass smaliClass = classes.iterator().next();
|
|
||||||
|
|
||||||
Location location = smaliClass.getLocationForSourcePosition(type, position);
|
|
||||||
|
|
||||||
if (location != null) {
|
|
||||||
locations.add(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor,
|
|
||||||
@NotNull final SourcePosition position) throws NoDataException {
|
|
||||||
Computable<Boolean> isSmaliFile = new Computable<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public Boolean compute() {
|
|
||||||
return position.getFile() instanceof SmaliFile;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ApplicationManager.getApplication().runReadAction(isSmaliFile);
|
|
||||||
|
|
||||||
if (!isSmaliFile.compute()) {
|
|
||||||
throw NoDataException.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
String className = getClassFromPosition(position);
|
|
||||||
return debugProcess.getRequestsManager().createClassPrepareRequest(new ClassPrepareRequestor() {
|
|
||||||
@Override
|
|
||||||
public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
|
|
||||||
requestor.processClassPrepare(debuggerProcess, referenceType);
|
|
||||||
}
|
|
||||||
}, className);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging;
|
|
||||||
|
|
||||||
import com.intellij.debugger.PositionManager;
|
|
||||||
import com.intellij.debugger.PositionManagerFactory;
|
|
||||||
import com.intellij.debugger.engine.DebugProcess;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SmaliPositionManagerFactory extends PositionManagerFactory {
|
|
||||||
@Override
|
|
||||||
public PositionManager createPositionManager(@NotNull DebugProcess process) {
|
|
||||||
return new SmaliPositionManager(process);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging;
|
|
||||||
|
|
||||||
import com.intellij.debugger.SourcePosition;
|
|
||||||
import com.intellij.debugger.engine.ContextUtil;
|
|
||||||
import com.intellij.debugger.engine.DebugProcessImpl.ResumeCommand;
|
|
||||||
import com.intellij.debugger.engine.SuspendContextImpl;
|
|
||||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
|
||||||
import com.intellij.debugger.impl.JvmSteppingCommandProvider;
|
|
||||||
import com.sun.jdi.request.StepRequest;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.SmaliLanguage;
|
|
||||||
|
|
||||||
public class SmaliSteppingCommandProvider extends JvmSteppingCommandProvider {
|
|
||||||
@Override
|
|
||||||
public ResumeCommand getStepOverCommand(@NotNull final SuspendContextImpl suspendContext, boolean ignoreBreakpoints,
|
|
||||||
int stepSize) {
|
|
||||||
|
|
||||||
final SourcePosition[] location = new SourcePosition[1];
|
|
||||||
|
|
||||||
suspendContext.getDebugProcess().getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
|
|
||||||
@Override protected void action() throws Exception {
|
|
||||||
location[0] = ContextUtil.getSourcePosition(suspendContext);
|
|
||||||
}
|
|
||||||
}) ;
|
|
||||||
|
|
||||||
if (location[0] != null && location[0].getFile().getLanguage() == SmaliLanguage.INSTANCE) {
|
|
||||||
return suspendContext.getDebugProcess().createStepOverCommand(suspendContext, ignoreBreakpoints,
|
|
||||||
StepRequest.STEP_MIN);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ArrayReference;
|
|
||||||
import com.sun.jdi.ClassNotLoadedException;
|
|
||||||
import com.sun.jdi.InvalidTypeException;
|
|
||||||
import com.sun.jdi.Value;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LazyArrayReference extends LazyObjectReference<ArrayReference> implements ArrayReference {
|
|
||||||
public LazyArrayReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Value getValue(int index) {
|
|
||||||
return getValue().getValue(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Value> getValues() {
|
|
||||||
return getValue().getValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Value> getValues(int index, int length) {
|
|
||||||
return getValue().getValues(index, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int length() {
|
|
||||||
return getValue().length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(int index, Value value) throws InvalidTypeException, ClassNotLoadedException {
|
|
||||||
getValue().setValue(index, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValues(int index, List<? extends Value> values, int srcIndex, int length) throws InvalidTypeException, ClassNotLoadedException {
|
|
||||||
getValue().setValues(index, values, srcIndex, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValues(List<? extends Value> values) throws InvalidTypeException, ClassNotLoadedException {
|
|
||||||
getValue().setValues(values);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.BooleanValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyBooleanValue extends LazyPrimitiveValue<BooleanValue> implements BooleanValue {
|
|
||||||
public LazyBooleanValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ByteValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyByteValue extends LazyComparablePrimitiveValue<ByteValue> implements ByteValue {
|
|
||||||
public LazyByteValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public byte value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.CharValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyCharValue extends LazyComparablePrimitiveValue<CharValue> implements CharValue {
|
|
||||||
public LazyCharValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public char value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ClassLoaderReference;
|
|
||||||
import com.sun.jdi.ReferenceType;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LazyClassLoaderReference extends LazyObjectReference<ClassLoaderReference>
|
|
||||||
implements ClassLoaderReference {
|
|
||||||
public LazyClassLoaderReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ReferenceType> definedClasses() {
|
|
||||||
return getValue().definedClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ReferenceType> visibleClasses() {
|
|
||||||
return getValue().visibleClasses();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ClassObjectReference;
|
|
||||||
import com.sun.jdi.ReferenceType;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyClassObjectReference extends LazyObjectReference<ClassObjectReference>
|
|
||||||
implements ClassObjectReference {
|
|
||||||
public LazyClassObjectReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReferenceType reflectedType() {
|
|
||||||
return getValue().reflectedType();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.PrimitiveValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyComparablePrimitiveValue<T extends PrimitiveValue & Comparable<T>> extends LazyPrimitiveValue<T>
|
|
||||||
implements Comparable<T> {
|
|
||||||
public LazyComparablePrimitiveValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(T o) {
|
|
||||||
return getValue().compareTo(o);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.DoubleValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyDoubleValue extends LazyComparablePrimitiveValue<DoubleValue> implements DoubleValue {
|
|
||||||
public LazyDoubleValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public double value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.FloatValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyFloatValue extends LazyComparablePrimitiveValue<FloatValue> implements FloatValue {
|
|
||||||
public LazyFloatValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public float value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.IntegerValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyIntegerValue extends LazyComparablePrimitiveValue<IntegerValue> implements IntegerValue {
|
|
||||||
public LazyIntegerValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.LongValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyLongValue extends LazyComparablePrimitiveValue<LongValue> implements LongValue {
|
|
||||||
public LazyLongValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public long value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.*;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class LazyObjectReference<T extends ObjectReference> extends LazyValue<T> implements ObjectReference {
|
|
||||||
|
|
||||||
public LazyObjectReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void disableCollection() {
|
|
||||||
getValue().disableCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public ReferenceType referenceType() {
|
|
||||||
return getValue().referenceType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Value getValue(Field sig) {
|
|
||||||
return getValue().getValue(sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Map<Field, Value> getValues(List<? extends Field> fields) {
|
|
||||||
return getValue().getValues(fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setValue(Field field, Value value) throws InvalidTypeException, ClassNotLoadedException {
|
|
||||||
getValue().setValue(field, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Value invokeMethod(ThreadReference thread, Method method, List<? extends Value> arguments, int options)
|
|
||||||
throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException,
|
|
||||||
InvocationException {
|
|
||||||
return getValue().invokeMethod(thread, method, arguments, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void enableCollection() {
|
|
||||||
getValue().enableCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isCollected() {
|
|
||||||
return getValue().isCollected();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public long uniqueID() {
|
|
||||||
return getValue().uniqueID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public List<ThreadReference> waitingThreads() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().waitingThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public ThreadReference owningThread() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().owningThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int entryCount() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().entryCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public List<ObjectReference> referringObjects(long maxReferrers) {
|
|
||||||
return getValue().referringObjects(maxReferrers);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.PrimitiveValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyPrimitiveValue<T extends PrimitiveValue> extends LazyValue<T> implements PrimitiveValue {
|
|
||||||
public LazyPrimitiveValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean booleanValue() {
|
|
||||||
return getValue().booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public byte byteValue() {
|
|
||||||
return getValue().byteValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public char charValue() {
|
|
||||||
return getValue().charValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public double doubleValue() {
|
|
||||||
return getValue().doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public float floatValue() {
|
|
||||||
return getValue().floatValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int intValue() {
|
|
||||||
return getValue().intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public long longValue() {
|
|
||||||
return getValue().longValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public short shortValue() {
|
|
||||||
return getValue().shortValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return getValue().toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ShortValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyShortValue extends LazyComparablePrimitiveValue<ShortValue> implements ShortValue {
|
|
||||||
public LazyShortValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public short value() {
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.psi.PsiSubstitutor;
|
|
||||||
import com.sun.jdi.ObjectReference;
|
|
||||||
import com.sun.jdi.StringReference;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyStringReference extends LazyObjectReference<StringReference> implements StringReference {
|
|
||||||
public LazyStringReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String value() {
|
|
||||||
ObjectReference objectReference = getValue();
|
|
||||||
if (!(objectReference instanceof StringReference)) {
|
|
||||||
throw new IllegalStateException(String.format("Expecting type String, but got %s. method=%s, register=%d",
|
|
||||||
objectReference.type().name(), this.method.getSignature(PsiSubstitutor.EMPTY), registerNumber));
|
|
||||||
}
|
|
||||||
return getValue().value();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.ThreadGroupReference;
|
|
||||||
import com.sun.jdi.ThreadReference;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LazyThreadGroupReference extends LazyObjectReference<ThreadGroupReference>
|
|
||||||
implements ThreadGroupReference {
|
|
||||||
|
|
||||||
public LazyThreadGroupReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String name() {
|
|
||||||
return getValue().name();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public ThreadGroupReference parent() {
|
|
||||||
return getValue().parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void resume() {
|
|
||||||
getValue().resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void suspend() {
|
|
||||||
getValue().suspend();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public List<ThreadGroupReference> threadGroups() {
|
|
||||||
return getValue().threadGroups();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public List<ThreadReference> threads() {
|
|
||||||
return getValue().threads();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.*;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LazyThreadReference extends LazyObjectReference<ThreadReference> implements ThreadReference {
|
|
||||||
public LazyThreadReference(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectReference currentContendedMonitor() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().currentContendedMonitor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forceEarlyReturn(Value value) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException {
|
|
||||||
getValue().forceEarlyReturn(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StackFrame frame(int index) throws IncompatibleThreadStateException {
|
|
||||||
return getValue().frame(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int frameCount() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().frameCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StackFrame> frames() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().frames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StackFrame> frames(int start, int length) throws IncompatibleThreadStateException {
|
|
||||||
return getValue().frames(start, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void interrupt() {
|
|
||||||
getValue().interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAtBreakpoint() {
|
|
||||||
return getValue().isAtBreakpoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuspended() {
|
|
||||||
return getValue().isSuspended();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return getValue().name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ObjectReference> ownedMonitors() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().ownedMonitors();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MonitorInfo> ownedMonitorsAndFrames() throws IncompatibleThreadStateException {
|
|
||||||
return getValue().ownedMonitorsAndFrames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void popFrames(StackFrame frame) throws IncompatibleThreadStateException {
|
|
||||||
getValue().popFrames(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resume() {
|
|
||||||
getValue().resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int status() {
|
|
||||||
return getValue().status();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop(ObjectReference throwable) throws InvalidTypeException {
|
|
||||||
getValue().stop(throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void suspend() {
|
|
||||||
getValue().suspend();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int suspendCount() {
|
|
||||||
return getValue().suspendCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ThreadGroupReference threadGroup() {
|
|
||||||
return getValue().threadGroup();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.debugger.DebuggerManagerEx;
|
|
||||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
|
||||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
|
||||||
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.Type;
|
|
||||||
import com.sun.jdi.Value;
|
|
||||||
import com.sun.jdi.VirtualMachine;
|
|
||||||
import org.jf.smalidea.debugging.SmaliCodeFragmentFactory;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class LazyValue<T extends Value> implements Value {
|
|
||||||
protected final int registerNumber;
|
|
||||||
protected final Project project;
|
|
||||||
protected final SmaliMethod method;
|
|
||||||
protected final String type;
|
|
||||||
|
|
||||||
private EvaluationContext evaluationContext;
|
|
||||||
private Value value;
|
|
||||||
|
|
||||||
public LazyValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
this.method = method;
|
|
||||||
this.project = project;
|
|
||||||
this.registerNumber = registerNumber;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LazyValue create(@Nonnull SmaliMethod method, @Nonnull Project project, int registerNumber,
|
|
||||||
@Nonnull String type) {
|
|
||||||
if (type.equals("B")) {
|
|
||||||
return new LazyByteValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("S")) {
|
|
||||||
return new LazyShortValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("J")) {
|
|
||||||
return new LazyLongValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("I")) {
|
|
||||||
return new LazyIntegerValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("F")) {
|
|
||||||
return new LazyFloatValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("D")) {
|
|
||||||
return new LazyDoubleValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Z")) {
|
|
||||||
return new LazyBooleanValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("C")) {
|
|
||||||
return new LazyCharValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("V")) {
|
|
||||||
return new LazyVoidValue(method, project, registerNumber, type);
|
|
||||||
} else if (type.startsWith("[")) {
|
|
||||||
return new LazyArrayReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Ljava/lang/String;")) {
|
|
||||||
return new LazyStringReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Ljava/lang/Class;")) {
|
|
||||||
return new LazyClassObjectReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Ljava/lang/ThreadGroup;")) {
|
|
||||||
return new LazyThreadGroupReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Ljava/lang/Thread;")) {
|
|
||||||
return new LazyThreadReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.equals("Ljava/lang/ClassLoader;")) {
|
|
||||||
return new LazyClassLoaderReference(method, project, registerNumber, type);
|
|
||||||
} else if (type.startsWith("L")) {
|
|
||||||
return new LazyObjectReference(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
return new LazyValue(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
protected T getNullableValue(boolean allowNull) {
|
|
||||||
if (value == null) {
|
|
||||||
try {
|
|
||||||
if (evaluationContext == null) {
|
|
||||||
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
|
|
||||||
evaluationContext = debuggerContext.createEvaluationContext();
|
|
||||||
if (evaluationContext == null) {
|
|
||||||
if (!allowNull) {
|
|
||||||
throw new IllegalStateException("Can't create evaluation context");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
value = SmaliCodeFragmentFactory.evaluateRegister(evaluationContext, method, registerNumber, type);
|
|
||||||
evaluationContext = null;
|
|
||||||
} catch (EvaluateException ex) {
|
|
||||||
if (!allowNull) {
|
|
||||||
throw new IllegalStateException(ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (T)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
protected T getValue() {
|
|
||||||
T value = getNullableValue(false);
|
|
||||||
assert value != null;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type type() {
|
|
||||||
return getValue().type();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VirtualMachine virtualMachine() {
|
|
||||||
if (evaluationContext != null) {
|
|
||||||
return ((VirtualMachineProxyImpl)evaluationContext.getDebugProcess().getVirtualMachineProxy())
|
|
||||||
.getVirtualMachine();
|
|
||||||
} else {
|
|
||||||
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
|
|
||||||
final DebugProcessImpl process = debuggerContext.getDebugProcess();
|
|
||||||
if (process != null) {
|
|
||||||
return process.getVirtualMachineProxy().getVirtualMachine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEvaluationContext(@Nonnull EvaluationContext evaluationContext) {
|
|
||||||
this.evaluationContext = evaluationContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean equals(Object obj) {
|
|
||||||
Value value = getNullableValue(true);
|
|
||||||
if (value != null) {
|
|
||||||
return value.equals(obj);
|
|
||||||
}
|
|
||||||
return super.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int hashCode() {
|
|
||||||
Value value = getNullableValue(true);
|
|
||||||
if (value != null) {
|
|
||||||
return value.hashCode();
|
|
||||||
}
|
|
||||||
return super.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
Value value = getNullableValue(true);
|
|
||||||
if (value != null) {
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.debugging.value;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.sun.jdi.VoidValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
|
|
||||||
public class LazyVoidValue extends LazyValue<VoidValue> implements VoidValue {
|
|
||||||
public LazyVoidValue(SmaliMethod method, Project project, int registerNumber, String type) {
|
|
||||||
super(method, project, registerNumber, type);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,214 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiField;
|
|
||||||
import com.intellij.psi.PsiMethod;
|
|
||||||
import com.intellij.psi.PsiModifierList;
|
|
||||||
import org.jf.dexlib2.AccessFlags;
|
|
||||||
import org.jf.dexlib2.base.reference.BaseTypeReference;
|
|
||||||
import org.jf.dexlib2.iface.Annotation;
|
|
||||||
import org.jf.dexlib2.iface.ClassDef;
|
|
||||||
import org.jf.dexlib2.iface.Field;
|
|
||||||
import org.jf.dexlib2.iface.Method;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SmalideaClassDef extends BaseTypeReference implements ClassDef {
|
|
||||||
private final PsiClass psiClass;
|
|
||||||
|
|
||||||
public SmalideaClassDef(PsiClass psiClass) {
|
|
||||||
this.psiClass = psiClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getAccessFlags() {
|
|
||||||
PsiModifierList modifierList = psiClass.getModifierList();
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
if (modifierList == null) {
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("public")) {
|
|
||||||
flags |= AccessFlags.PUBLIC.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("final")) {
|
|
||||||
flags |= AccessFlags.FINAL.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("abstract")) {
|
|
||||||
flags |= AccessFlags.ABSTRACT.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psiClass.isInterface()) {
|
|
||||||
flags |= AccessFlags.INTERFACE.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psiClass.isEnum()) {
|
|
||||||
flags |= AccessFlags.ENUM.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psiClass.isAnnotationType()) {
|
|
||||||
flags |= AccessFlags.ANNOTATION.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getType() {
|
|
||||||
return NameUtils.javaToSmaliType(psiClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getSuperclass() {
|
|
||||||
PsiClass superClass = psiClass.getSuperClass();
|
|
||||||
if (superClass == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return NameUtils.javaToSmaliType(superClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<String> getInterfaces() {
|
|
||||||
List<String> interfaceList = Lists.newArrayList();
|
|
||||||
PsiClass[] interfaces = psiClass.getInterfaces();
|
|
||||||
if (interfaces == null) {
|
|
||||||
return interfaceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PsiClass psiClass: interfaces) {
|
|
||||||
interfaceList.add(NameUtils.javaToSmaliType(psiClass));
|
|
||||||
}
|
|
||||||
|
|
||||||
return interfaceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getSourceFile() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Field> getStaticFields() {
|
|
||||||
return Iterables.transform(
|
|
||||||
Iterables.filter(Arrays.asList(psiClass.getFields()), new Predicate<PsiField>() {
|
|
||||||
@Override public boolean apply(PsiField psiField) {
|
|
||||||
PsiModifierList modifierList = psiField.getModifierList();
|
|
||||||
if (modifierList == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return modifierList.hasModifierProperty("static");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new Function<PsiField, Field>() {
|
|
||||||
@Nullable @Override public Field apply(@Nullable PsiField psiField) {
|
|
||||||
return new SmalideaField(psiField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Field> getInstanceFields() {
|
|
||||||
return Iterables.transform(
|
|
||||||
Iterables.filter(Arrays.asList(psiClass.getFields()), new Predicate<PsiField>() {
|
|
||||||
@Override public boolean apply(PsiField psiField) {
|
|
||||||
PsiModifierList modifierList = psiField.getModifierList();
|
|
||||||
if (modifierList == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return !modifierList.hasModifierProperty("static");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new Function<PsiField, Field>() {
|
|
||||||
@Nullable @Override public Field apply(@Nullable PsiField psiField) {
|
|
||||||
return new SmalideaField(psiField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Field> getFields() {
|
|
||||||
return Iterables.concat(getStaticFields(), getInstanceFields());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Method> getDirectMethods() {
|
|
||||||
return Iterables.transform(
|
|
||||||
Iterables.filter(
|
|
||||||
Iterables.concat(
|
|
||||||
Arrays.asList(psiClass.getConstructors()),
|
|
||||||
Arrays.asList(psiClass.getMethods())),
|
|
||||||
new Predicate<PsiMethod>() {
|
|
||||||
@Override public boolean apply(PsiMethod psiMethod) {
|
|
||||||
PsiModifierList modifierList = psiMethod.getModifierList();
|
|
||||||
return modifierList.hasModifierProperty("static") ||
|
|
||||||
modifierList.hasModifierProperty("private") ||
|
|
||||||
modifierList.hasModifierProperty("constructor");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new Function<PsiMethod, Method>() {
|
|
||||||
@Nullable @Override public Method apply(PsiMethod psiMethod) {
|
|
||||||
return new SmalideaMethod(psiMethod);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Method> getVirtualMethods() {
|
|
||||||
return Iterables.transform(
|
|
||||||
Iterables.filter(Arrays.asList(psiClass.getMethods()), new Predicate<PsiMethod>() {
|
|
||||||
@Override public boolean apply(PsiMethod psiMethod) {
|
|
||||||
PsiModifierList modifierList = psiMethod.getModifierList();
|
|
||||||
return !modifierList.hasModifierProperty("static") &&
|
|
||||||
!modifierList.hasModifierProperty("private") &&
|
|
||||||
!modifierList.hasModifierProperty("constructor");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new Function<PsiMethod, Method>() {
|
|
||||||
@Nullable @Override public Method apply(PsiMethod psiMethod) {
|
|
||||||
return new SmalideaMethod(psiMethod);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Method> getMethods() {
|
|
||||||
return Iterables.concat(getDirectMethods(), getVirtualMethods());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.base.BaseExceptionHandler;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliCatchStatement;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliClassTypeElement;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliLabel;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliLabelReference;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class SmalideaExceptionHandler extends BaseExceptionHandler {
|
|
||||||
@Nonnull private final SmaliCatchStatement catchStatement;
|
|
||||||
|
|
||||||
public SmalideaExceptionHandler(@Nonnull SmaliCatchStatement catchStatement) {
|
|
||||||
this.catchStatement = catchStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getExceptionType() {
|
|
||||||
SmaliClassTypeElement exceptionType = catchStatement.getExceptionType();
|
|
||||||
if (exceptionType == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return exceptionType.getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getHandlerCodeAddress() {
|
|
||||||
SmaliLabelReference handlerLabel = catchStatement.getHandlerLabel();
|
|
||||||
// TODO: how to handle a reference to a non-existent label..
|
|
||||||
SmaliLabel smaliLabel = handlerLabel.resolve();
|
|
||||||
return smaliLabel.getOffset() / 2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiField;
|
|
||||||
import com.intellij.psi.PsiModifierList;
|
|
||||||
import org.jf.dexlib2.AccessFlags;
|
|
||||||
import org.jf.dexlib2.base.reference.BaseFieldReference;
|
|
||||||
import org.jf.dexlib2.iface.Annotation;
|
|
||||||
import org.jf.dexlib2.iface.Field;
|
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliField;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SmalideaField extends BaseFieldReference implements Field {
|
|
||||||
private final PsiField psiField;
|
|
||||||
|
|
||||||
public SmalideaField(PsiField psiField) {
|
|
||||||
this.psiField = psiField;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getAccessFlags() {
|
|
||||||
if (psiField instanceof SmaliField) {
|
|
||||||
return ((SmaliField)psiField).getModifierList().getAccessFlags();
|
|
||||||
} else {
|
|
||||||
int flags = 0;
|
|
||||||
PsiModifierList modifierList = psiField.getModifierList();
|
|
||||||
if (modifierList == null) {
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
if (modifierList.hasModifierProperty("public")) {
|
|
||||||
flags |= AccessFlags.PUBLIC.getValue();
|
|
||||||
} else if (modifierList.hasModifierProperty("protected")) {
|
|
||||||
flags |= AccessFlags.PROTECTED.getValue();
|
|
||||||
} else if (modifierList.hasModifierProperty("private")) {
|
|
||||||
flags |= AccessFlags.PRIVATE.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("static")) {
|
|
||||||
flags |= AccessFlags.STATIC.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("final")) {
|
|
||||||
flags |= AccessFlags.FINAL.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("volatile")) {
|
|
||||||
flags |= AccessFlags.VOLATILE.getValue();
|
|
||||||
}
|
|
||||||
// TODO: how do we tell if it's an enum?
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getDefiningClass() {
|
|
||||||
PsiClass containingClass = psiField.getContainingClass();
|
|
||||||
if (containingClass == null) {
|
|
||||||
throw new RuntimeException("I don't know what to do here... Is this even possible?");
|
|
||||||
}
|
|
||||||
return NameUtils.javaToSmaliType(containingClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getName() {
|
|
||||||
return psiField.getNameIdentifier().getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getType() {
|
|
||||||
return NameUtils.javaToSmaliType(psiField.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public EncodedValue getInitialValue() {
|
|
||||||
// TODO: implement this. Not needed for method analysis
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
|
|
||||||
// TODO: implement this. Not needed for method analysis
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,214 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiMethod;
|
|
||||||
import com.intellij.psi.PsiModifierList;
|
|
||||||
import com.intellij.psi.PsiParameter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.dexlib2.AccessFlags;
|
|
||||||
import org.jf.dexlib2.base.reference.BaseMethodReference;
|
|
||||||
import org.jf.dexlib2.iface.*;
|
|
||||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
|
||||||
import org.jf.smalidea.dexlib.instruction.SmalideaInstruction;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliCatchStatement;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMethod;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SmalideaMethod extends BaseMethodReference implements Method {
|
|
||||||
private final PsiMethod psiMethod;
|
|
||||||
|
|
||||||
public SmalideaMethod(@NotNull PsiMethod psiMethod) {
|
|
||||||
this.psiMethod = psiMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getDefiningClass() {
|
|
||||||
PsiClass cls = psiMethod.getContainingClass();
|
|
||||||
assert cls != null;
|
|
||||||
return NameUtils.javaToSmaliType(cls);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
|
|
||||||
PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
|
|
||||||
|
|
||||||
return Lists.transform(Arrays.asList(parameters), new Function<PsiParameter, MethodParameter>() {
|
|
||||||
@Nullable @Override
|
|
||||||
public MethodParameter apply(@Nullable PsiParameter psiParameter) {
|
|
||||||
if (psiParameter == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new SmalideaMethodParameter(psiParameter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getAccessFlags() {
|
|
||||||
if (psiMethod instanceof SmaliMethod) {
|
|
||||||
return ((SmaliMethod)psiMethod).getModifierList().getAccessFlags();
|
|
||||||
} else {
|
|
||||||
int flags = 0;
|
|
||||||
PsiModifierList modifierList = psiMethod.getModifierList();
|
|
||||||
if (modifierList.hasModifierProperty("public")) {
|
|
||||||
flags |= AccessFlags.PUBLIC.getValue();
|
|
||||||
} else if (modifierList.hasModifierProperty("protected")) {
|
|
||||||
flags |= AccessFlags.PROTECTED.getValue();
|
|
||||||
} else if (modifierList.hasModifierProperty("private")) {
|
|
||||||
flags |= AccessFlags.PRIVATE.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("static")) {
|
|
||||||
flags |= AccessFlags.STATIC.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("final")) {
|
|
||||||
flags |= AccessFlags.FINAL.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isNative = false;
|
|
||||||
if (modifierList.hasModifierProperty("native")) {
|
|
||||||
flags |= AccessFlags.NATIVE.getValue();
|
|
||||||
isNative = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("synchronized")) {
|
|
||||||
if (isNative) {
|
|
||||||
flags |= AccessFlags.SYNCHRONIZED.getValue();
|
|
||||||
} else {
|
|
||||||
flags |= AccessFlags.DECLARED_SYNCHRONIZED.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psiMethod.isVarArgs()) {
|
|
||||||
flags |= AccessFlags.VARARGS.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("abstract")) {
|
|
||||||
flags |= AccessFlags.ABSTRACT.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modifierList.hasModifierProperty("strictfp")) {
|
|
||||||
flags |= AccessFlags.STRICTFP.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psiMethod.isConstructor()) {
|
|
||||||
flags |= AccessFlags.CONSTRUCTOR.getValue();
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
|
|
||||||
// TODO: implement this
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public MethodImplementation getImplementation() {
|
|
||||||
if (psiMethod instanceof SmaliMethod) {
|
|
||||||
final SmaliMethod smaliMethod = (SmaliMethod)this.psiMethod;
|
|
||||||
|
|
||||||
List<SmaliInstruction> instructions = smaliMethod.getInstructions();
|
|
||||||
if (instructions.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: cache this?
|
|
||||||
return new MethodImplementation() {
|
|
||||||
@Override public int getRegisterCount() {
|
|
||||||
return smaliMethod.getRegisterCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
|
|
||||||
return Lists.transform(smaliMethod.getInstructions(),
|
|
||||||
new Function<SmaliInstruction, Instruction>() {
|
|
||||||
@Override
|
|
||||||
public Instruction apply(SmaliInstruction smaliInstruction) {
|
|
||||||
return SmalideaInstruction.of(smaliInstruction);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks() {
|
|
||||||
return Lists.transform(smaliMethod.getCatchStatements(),
|
|
||||||
new Function<SmaliCatchStatement, TryBlock<? extends ExceptionHandler>>() {
|
|
||||||
@Override
|
|
||||||
public TryBlock<? extends ExceptionHandler> apply(
|
|
||||||
SmaliCatchStatement smaliCatchStatement) {
|
|
||||||
assert smaliCatchStatement != null;
|
|
||||||
return new SmalideaTryBlock(smaliCatchStatement);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() {
|
|
||||||
// TODO: implement this
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getName() {
|
|
||||||
return psiMethod.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends CharSequence> getParameterTypes() {
|
|
||||||
PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
|
|
||||||
|
|
||||||
return Lists.transform(Arrays.asList(parameters), new Function<PsiParameter, CharSequence>() {
|
|
||||||
@Nullable @Override
|
|
||||||
public CharSequence apply(@Nullable PsiParameter psiParameter) {
|
|
||||||
if (psiParameter == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return psiParameter.getText();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getReturnType() {
|
|
||||||
return psiMethod.getReturnTypeElement().getText();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.intellij.psi.PsiParameter;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.dexlib2.base.BaseMethodParameter;
|
|
||||||
import org.jf.dexlib2.iface.Annotation;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
import org.jf.smalidea.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SmalideaMethodParameter extends BaseMethodParameter {
|
|
||||||
private final PsiParameter psiParameter;
|
|
||||||
|
|
||||||
public SmalideaMethodParameter(PsiParameter psiParameter) {
|
|
||||||
this.psiParameter = psiParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
|
|
||||||
// TODO: implement this
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getName() {
|
|
||||||
return StringUtils.parseQuotedString(psiParameter.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public String getType() {
|
|
||||||
return NameUtils.javaToSmaliType(psiParameter.getType());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.base.BaseTryBlock;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliCatchStatement;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmalideaTryBlock extends BaseTryBlock<SmalideaExceptionHandler> {
|
|
||||||
@Nonnull private final SmaliCatchStatement catchStatement;
|
|
||||||
|
|
||||||
public SmalideaTryBlock(@Nonnull SmaliCatchStatement catchStatement) {
|
|
||||||
this.catchStatement = catchStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getCodeUnitCount() {
|
|
||||||
int endOffset = catchStatement.getEndLabel().resolve().getOffset() / 2;
|
|
||||||
return endOffset - getStartCodeAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getStartCodeAddress() {
|
|
||||||
// TODO: how to handle references to non-existent labels?
|
|
||||||
return catchStatement.getStartLabel().resolve().getOffset() / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends SmalideaExceptionHandler> getExceptionHandlers() {
|
|
||||||
return Arrays.asList(new SmalideaExceptionHandler(catchStatement));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package org.jf.smalidea.dexlib.analysis;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.impl.ResolveScopeManager;
|
|
||||||
import org.jf.dexlib2.analysis.ClassProvider;
|
|
||||||
import org.jf.dexlib2.iface.ClassDef;
|
|
||||||
import org.jf.smalidea.dexlib.SmalideaClassDef;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class SmalideaClassProvider implements ClassProvider {
|
|
||||||
private final Project project;
|
|
||||||
private final VirtualFile file;
|
|
||||||
|
|
||||||
public SmalideaClassProvider(@Nonnull Project project, @Nonnull VirtualFile file) {
|
|
||||||
this.project = project;
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public ClassDef getClassDef(String type) {
|
|
||||||
ResolveScopeManager manager = ResolveScopeManager.getInstance(project);
|
|
||||||
PsiClass psiClass = NameUtils.resolveSmaliType(project, manager.getDefaultResolveScope(file), type);
|
|
||||||
if (psiClass != null) {
|
|
||||||
return new SmalideaClassDef(psiClass);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliArrayDataElement;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmalideaArrayPayload extends SmalideaInstruction implements ArrayPayload {
|
|
||||||
public SmalideaArrayPayload(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getElementWidth() {
|
|
||||||
return (int)psiInstruction.getArrayDataWidth().getIntegralValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<Number> getArrayElements() {
|
|
||||||
return Lists.transform(psiInstruction.getArrayDataElements(), new Function<SmaliArrayDataElement, Number>() {
|
|
||||||
@Nullable @Override public Number apply(SmaliArrayDataElement smaliArrayDataElement) {
|
|
||||||
return smaliArrayDataElement.getValue().getIntegralValue();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getCodeUnits() {
|
|
||||||
return psiInstruction.getInstructionSize()/2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,220 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.psi.PsiType;
|
|
||||||
import org.jf.dexlib2.Opcode;
|
|
||||||
import org.jf.dexlib2.ReferenceType;
|
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
|
||||||
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
|
|
||||||
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference;
|
|
||||||
import org.jf.dexlib2.immutable.reference.ImmutableStringReference;
|
|
||||||
import org.jf.dexlib2.immutable.reference.ImmutableTypeReference;
|
|
||||||
import org.jf.smalidea.psi.impl.*;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
import org.jf.smalidea.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class SmalideaInstruction implements Instruction {
|
|
||||||
@Nonnull protected final SmaliInstruction psiInstruction;
|
|
||||||
|
|
||||||
protected SmalideaInstruction(@Nonnull SmaliInstruction instruction) {
|
|
||||||
this.psiInstruction = instruction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public static SmalideaInstruction of(SmaliInstruction instruction) {
|
|
||||||
switch (instruction.getOpcode().format) {
|
|
||||||
case Format10t:
|
|
||||||
return new SmalideaInstruction10t(instruction);
|
|
||||||
case Format10x:
|
|
||||||
return new SmalideaInstruction10x(instruction);
|
|
||||||
case Format11n:
|
|
||||||
return new SmalideaInstruction11n(instruction);
|
|
||||||
case Format11x:
|
|
||||||
return new SmalideaInstruction11x(instruction);
|
|
||||||
case Format12x:
|
|
||||||
return new SmalideaInstruction12x(instruction);
|
|
||||||
case Format20t:
|
|
||||||
return new SmalideaInstruction20t(instruction);
|
|
||||||
case Format21c:
|
|
||||||
return new SmalideaInstruction21c(instruction);
|
|
||||||
case Format21ih:
|
|
||||||
return new SmalideaInstruction21ih(instruction);
|
|
||||||
case Format21lh:
|
|
||||||
return new SmalideaInstruction21lh(instruction);
|
|
||||||
case Format21s:
|
|
||||||
return new SmalideaInstruction21s(instruction);
|
|
||||||
case Format21t:
|
|
||||||
return new SmalideaInstruction21t(instruction);
|
|
||||||
case Format22b:
|
|
||||||
return new SmalideaInstruction22b(instruction);
|
|
||||||
case Format22c:
|
|
||||||
return new SmalideaInstruction22c(instruction);
|
|
||||||
case Format22s:
|
|
||||||
return new SmalideaInstruction22s(instruction);
|
|
||||||
case Format22t:
|
|
||||||
return new SmalideaInstruction22t(instruction);
|
|
||||||
case Format22x:
|
|
||||||
return new SmalideaInstruction22x(instruction);
|
|
||||||
case Format23x:
|
|
||||||
return new SmalideaInstruction23x(instruction);
|
|
||||||
case Format30t:
|
|
||||||
return new SmalideaInstruction30t(instruction);
|
|
||||||
case Format31c:
|
|
||||||
return new SmalideaInstruction31c(instruction);
|
|
||||||
case Format31i:
|
|
||||||
return new SmalideaInstruction31i(instruction);
|
|
||||||
case Format31t:
|
|
||||||
return new SmalideaInstruction31t(instruction);
|
|
||||||
case Format32x:
|
|
||||||
return new SmalideaInstruction32x(instruction);
|
|
||||||
case Format35c:
|
|
||||||
return new SmalideaInstruction35c(instruction);
|
|
||||||
case Format3rc:
|
|
||||||
return new SmalideaInstruction3rc(instruction);
|
|
||||||
case Format51l:
|
|
||||||
return new SmalideaInstruction51l(instruction);
|
|
||||||
case PackedSwitchPayload:
|
|
||||||
return new SmalideaPackedSwitchPayload(instruction);
|
|
||||||
case SparseSwitchPayload:
|
|
||||||
return new SmalideaSparseSwitchPayload(instruction);
|
|
||||||
case ArrayPayload:
|
|
||||||
return new SmalideaArrayPayload(instruction);
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unexpected instruction type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull public Opcode getOpcode() {
|
|
||||||
return psiInstruction.getOpcode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCodeUnits() {
|
|
||||||
return getOpcode().format.size / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCodeOffset() {
|
|
||||||
SmaliLabelReference labelReference = psiInstruction.getTarget();
|
|
||||||
if (labelReference == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliLabel label = labelReference.resolve();
|
|
||||||
if (label == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return (label.getOffset() - psiInstruction.getOffset())/2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRegisterCount() {
|
|
||||||
return psiInstruction.getRegisterCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRegisterA() {
|
|
||||||
return psiInstruction.getRegister(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRegisterB() {
|
|
||||||
return psiInstruction.getRegister(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRegisterC() {
|
|
||||||
return psiInstruction.getRegister(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNarrowLiteral() {
|
|
||||||
SmaliLiteral literal = psiInstruction.getLiteral();
|
|
||||||
if (literal == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (int)literal.getIntegralValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getWideLiteral() {
|
|
||||||
SmaliLiteral literal = psiInstruction.getLiteral();
|
|
||||||
if (literal == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return literal.getIntegralValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull public Reference getReference() {
|
|
||||||
switch (getReferenceType()) {
|
|
||||||
case ReferenceType.STRING:
|
|
||||||
return new ImmutableStringReference(StringUtils.parseQuotedString(
|
|
||||||
psiInstruction.getLiteral().getText()));
|
|
||||||
case ReferenceType.TYPE:
|
|
||||||
SmaliTypeElement typeReference = psiInstruction.getTypeReference();
|
|
||||||
assert typeReference != null;
|
|
||||||
return new ImmutableTypeReference(typeReference.getText());
|
|
||||||
case ReferenceType.METHOD:
|
|
||||||
SmaliMethodReference methodReference = psiInstruction.getMethodReference();
|
|
||||||
assert methodReference != null;
|
|
||||||
String containingClass = methodReference.getContainingType().getText();
|
|
||||||
List<String> paramTypes =
|
|
||||||
Lists.transform(methodReference.getParameterTypes(), new Function<PsiType, String>() {
|
|
||||||
@Nullable @Override public String apply(@Nullable PsiType psiType) {
|
|
||||||
if (psiType == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return NameUtils.javaToSmaliType(psiType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return new ImmutableMethodReference(containingClass,
|
|
||||||
methodReference.getName(),
|
|
||||||
paramTypes,
|
|
||||||
methodReference.getReturnType().getText());
|
|
||||||
case ReferenceType.FIELD:
|
|
||||||
SmaliFieldReference fieldReference = psiInstruction.getFieldReference();
|
|
||||||
assert fieldReference != null;
|
|
||||||
containingClass = fieldReference.getContainingType().getText();
|
|
||||||
return new ImmutableFieldReference(containingClass,
|
|
||||||
fieldReference.getName(),
|
|
||||||
fieldReference.getFieldType().getText());
|
|
||||||
}
|
|
||||||
assert false;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getReferenceType() {
|
|
||||||
return psiInstruction.getOpcode().referenceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction10t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction10t extends SmalideaInstruction implements Instruction10t {
|
|
||||||
public SmalideaInstruction10t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction10x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction10x extends SmalideaInstruction implements Instruction10x {
|
|
||||||
public SmalideaInstruction10x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11n;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction11n extends SmalideaInstruction implements Instruction11n {
|
|
||||||
public SmalideaInstruction11n(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction11x extends SmalideaInstruction implements Instruction11x {
|
|
||||||
public SmalideaInstruction11x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction12x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction12x extends SmalideaInstruction implements Instruction12x {
|
|
||||||
public SmalideaInstruction12x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction20t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction20t extends SmalideaInstruction implements Instruction20t {
|
|
||||||
public SmalideaInstruction20t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction21c extends SmalideaInstruction implements Instruction21c {
|
|
||||||
public SmalideaInstruction21c(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21ih;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction21ih extends SmalideaInstruction implements Instruction21ih {
|
|
||||||
public SmalideaInstruction21ih(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public short getHatLiteral() {
|
|
||||||
return (short)(getNarrowLiteral() >>> 16);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21lh;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction21lh extends SmalideaInstruction implements Instruction21lh {
|
|
||||||
public SmalideaInstruction21lh(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public short getHatLiteral() {
|
|
||||||
return (short)(getWideLiteral() >>> 48);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21s;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction21s extends SmalideaInstruction implements Instruction21s {
|
|
||||||
public SmalideaInstruction21s(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction21t extends SmalideaInstruction implements Instruction21t {
|
|
||||||
public SmalideaInstruction21t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22b;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction22b extends SmalideaInstruction implements Instruction22b {
|
|
||||||
public SmalideaInstruction22b(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction22c extends SmalideaInstruction implements Instruction22c {
|
|
||||||
public SmalideaInstruction22c(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22s;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction22s extends SmalideaInstruction implements Instruction22s {
|
|
||||||
public SmalideaInstruction22s(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction22t extends SmalideaInstruction implements Instruction22t {
|
|
||||||
public SmalideaInstruction22t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction22x extends SmalideaInstruction implements Instruction22x {
|
|
||||||
public SmalideaInstruction22x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction23x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction23x extends SmalideaInstruction implements Instruction23x {
|
|
||||||
public SmalideaInstruction23x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction30t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction30t extends SmalideaInstruction implements Instruction30t {
|
|
||||||
public SmalideaInstruction30t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31c;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction31c extends SmalideaInstruction implements Instruction31c {
|
|
||||||
public SmalideaInstruction31c(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction31i extends SmalideaInstruction implements Instruction31i {
|
|
||||||
public SmalideaInstruction31i(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31t;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction31t extends SmalideaInstruction implements Instruction31t {
|
|
||||||
public SmalideaInstruction31t(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction32x;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction32x extends SmalideaInstruction implements Instruction32x {
|
|
||||||
public SmalideaInstruction32x(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction35c extends SmalideaInstruction implements Instruction35c {
|
|
||||||
public SmalideaInstruction35c(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterC() {
|
|
||||||
return psiInstruction.getRegister(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterD() {
|
|
||||||
return psiInstruction.getRegister(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterE() {
|
|
||||||
return psiInstruction.getRegister(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterF() {
|
|
||||||
return psiInstruction.getRegister(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterG() {
|
|
||||||
return psiInstruction.getRegister(4);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction3rc;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction3rc extends SmalideaInstruction implements Instruction3rc {
|
|
||||||
public SmalideaInstruction3rc(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getStartRegister() {
|
|
||||||
return psiInstruction.getRegister(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getRegisterCount() {
|
|
||||||
return psiInstruction.getRegister(1) - getStartRegister() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction51l;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliInstruction;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class SmalideaInstruction51l extends SmalideaInstruction implements Instruction51l {
|
|
||||||
public SmalideaInstruction51l(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.jf.dexlib2.Opcode;
|
|
||||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload;
|
|
||||||
import org.jf.smalidea.psi.impl.*;
|
|
||||||
import org.jf.smalidea.util.InstructionUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmalideaPackedSwitchPayload extends SmalideaInstruction implements PackedSwitchPayload {
|
|
||||||
public SmalideaPackedSwitchPayload(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends SwitchElement> getSwitchElements() {
|
|
||||||
final SmaliLiteral startKey = psiInstruction.getPackedSwitchStartKey();
|
|
||||||
assert startKey != null;
|
|
||||||
List<SmaliPackedSwitchElement> elements = psiInstruction.getPackedSwitchElements();
|
|
||||||
|
|
||||||
SmaliMethod smaliMethod = psiInstruction.getParentMethod();
|
|
||||||
SmaliInstruction packedSwitchInstruction = InstructionUtils.findFirstInstructionWithTarget(
|
|
||||||
smaliMethod, Opcode.PACKED_SWITCH, psiInstruction.getOffset());
|
|
||||||
final int baseOffset;
|
|
||||||
|
|
||||||
if (packedSwitchInstruction == null) {
|
|
||||||
baseOffset = 0;
|
|
||||||
} else {
|
|
||||||
baseOffset = packedSwitchInstruction.getOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SwitchElement> newElements = Lists.newArrayList();
|
|
||||||
// TODO: check for integer wraparound (how does art/dalvik handle that?)
|
|
||||||
int initialKey = (int)startKey.getIntegralValue();
|
|
||||||
for (int i=0; i<elements.size(); i++) {
|
|
||||||
final SmaliPackedSwitchElement element = elements.get(i);
|
|
||||||
|
|
||||||
final int key = initialKey + i;
|
|
||||||
|
|
||||||
newElements.add(new SwitchElement() {
|
|
||||||
@Override public int getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getOffset() {
|
|
||||||
SmaliLabelReference labelReference = element.getTarget();
|
|
||||||
if (labelReference == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliLabel label = labelReference.resolve();
|
|
||||||
if (label == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (label.getOffset() - baseOffset) / 2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return newElements;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getCodeUnits() {
|
|
||||||
return psiInstruction.getInstructionSize()/2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.dexlib.instruction;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.jf.dexlib2.Opcode;
|
|
||||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload;
|
|
||||||
import org.jf.smalidea.psi.impl.*;
|
|
||||||
import org.jf.smalidea.util.InstructionUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmalideaSparseSwitchPayload extends SmalideaInstruction implements SparseSwitchPayload {
|
|
||||||
public SmalideaSparseSwitchPayload(@Nonnull SmaliInstruction instruction) {
|
|
||||||
super(instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull @Override public List<? extends SwitchElement> getSwitchElements() {
|
|
||||||
List<SmaliSparseSwitchElement> elements = psiInstruction.getSparseSwitchElements();
|
|
||||||
|
|
||||||
SmaliMethod smaliMethod = psiInstruction.getParentMethod();
|
|
||||||
SmaliInstruction sparseSwitchInstruction = InstructionUtils.findFirstInstructionWithTarget(
|
|
||||||
smaliMethod, Opcode.SPARSE_SWITCH, psiInstruction.getOffset());
|
|
||||||
final int baseOffset;
|
|
||||||
|
|
||||||
if (sparseSwitchInstruction == null) {
|
|
||||||
baseOffset = 0;
|
|
||||||
} else {
|
|
||||||
baseOffset = sparseSwitchInstruction.getOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Lists.transform(elements, new Function<SmaliSparseSwitchElement, SwitchElement>() {
|
|
||||||
@Override public SwitchElement apply(final SmaliSparseSwitchElement element) {
|
|
||||||
return new SwitchElement() {
|
|
||||||
@Override public int getKey() {
|
|
||||||
return (int)element.getKey().getIntegralValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getOffset() {
|
|
||||||
SmaliLabelReference labelReference = element.getTarget();
|
|
||||||
if (labelReference == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliLabel label = labelReference.resolve();
|
|
||||||
if (label == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (label.getOffset() - baseOffset) / 2;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getCodeUnits() {
|
|
||||||
return psiInstruction.getInstructionSize()/2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.errorReporting;
|
|
||||||
|
|
||||||
import com.intellij.diagnostic.IdeErrorsDialog;
|
|
||||||
import com.intellij.diagnostic.LogMessageEx;
|
|
||||||
import com.intellij.diagnostic.ReportMessages;
|
|
||||||
import com.intellij.errorreport.bean.ErrorBean;
|
|
||||||
import com.intellij.ide.DataManager;
|
|
||||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
|
||||||
import com.intellij.ide.plugins.PluginManager;
|
|
||||||
import com.intellij.idea.IdeaLogger;
|
|
||||||
import com.intellij.notification.NotificationListener;
|
|
||||||
import com.intellij.notification.NotificationType;
|
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
|
||||||
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
|
|
||||||
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
|
|
||||||
import com.intellij.openapi.diagnostic.SubmittedReportInfo;
|
|
||||||
import com.intellij.openapi.extensions.PluginId;
|
|
||||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
|
||||||
import com.intellij.openapi.progress.ProgressManager;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.util.Consumer;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends crash reports to Github.
|
|
||||||
*
|
|
||||||
* Based on the go-lang plugin's error reporter
|
|
||||||
* (https://github.com/dlsniper/google-go-lang-idea-plugin/commit/c451006cc9fc926ca347189951baa94f4032c5c4)
|
|
||||||
*/
|
|
||||||
public class ErrorReporter extends ErrorReportSubmitter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReportActionText() {
|
|
||||||
return "Report as issue on smali's github repo";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, Component parentComponent,
|
|
||||||
final Consumer<SubmittedReportInfo> consumer) {
|
|
||||||
IdeaLoggingEvent event = events[0];
|
|
||||||
ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
|
|
||||||
|
|
||||||
final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
|
|
||||||
|
|
||||||
bean.setDescription(additionalInfo);
|
|
||||||
bean.setMessage(event.getMessage());
|
|
||||||
|
|
||||||
Throwable throwable = event.getThrowable();
|
|
||||||
if (throwable != null) {
|
|
||||||
final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable);
|
|
||||||
if (pluginId != null) {
|
|
||||||
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
|
|
||||||
if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
|
|
||||||
bean.setPluginName(ideaPluginDescriptor.getName());
|
|
||||||
bean.setPluginVersion(ideaPluginDescriptor.getVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object data = event.getData();
|
|
||||||
|
|
||||||
if (data instanceof LogMessageEx) {
|
|
||||||
bean.setAttachments(((LogMessageEx)data).getAttachments());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> reportValues = ITNProxy.createParameters(bean);
|
|
||||||
|
|
||||||
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
|
||||||
|
|
||||||
Consumer<String> successCallback = new Consumer<String>() {
|
|
||||||
@Override
|
|
||||||
public void consume(String token) {
|
|
||||||
final SubmittedReportInfo reportInfo = new SubmittedReportInfo(
|
|
||||||
null, "Issue " + token, SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
|
|
||||||
consumer.consume(reportInfo);
|
|
||||||
|
|
||||||
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
|
|
||||||
"Submitted",
|
|
||||||
NotificationType.INFORMATION,
|
|
||||||
null).setImportant(false).notify(project);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Consumer<Exception> errorCallback = new Consumer<Exception>() {
|
|
||||||
@Override
|
|
||||||
public void consume(Exception e) {
|
|
||||||
String message = String.format("<html>There was an error while creating a GitHub issue: %s<br>" +
|
|
||||||
"Please consider manually creating an issue on the " +
|
|
||||||
"<a href=\"https://github.com/JesusFreke/smali/issues\">Smali Issue Tracker</a></html>",
|
|
||||||
e.getMessage());
|
|
||||||
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
|
|
||||||
message,
|
|
||||||
NotificationType.ERROR,
|
|
||||||
NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GithubFeedbackTask task = new GithubFeedbackTask(project, "Submitting error report", true, reportValues,
|
|
||||||
successCallback, errorCallback);
|
|
||||||
|
|
||||||
if (project == null) {
|
|
||||||
task.run(new EmptyProgressIndicator());
|
|
||||||
} else {
|
|
||||||
ProgressManager.getInstance().run(task);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.errorReporting;
|
|
||||||
|
|
||||||
import com.google.common.io.CharStreams;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
|
|
||||||
import com.intellij.ide.plugins.PluginManager;
|
|
||||||
import com.intellij.openapi.extensions.PluginId;
|
|
||||||
import com.intellij.openapi.progress.ProgressIndicator;
|
|
||||||
import com.intellij.openapi.progress.Task;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.util.Consumer;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class GithubFeedbackTask extends Task.Backgroundable {
|
|
||||||
private final Consumer<String> myCallback;
|
|
||||||
private final Consumer<Exception> myErrorCallback;
|
|
||||||
private final Map<String, String> myParams;
|
|
||||||
|
|
||||||
public GithubFeedbackTask(@Nullable Project project,
|
|
||||||
@NotNull String title,
|
|
||||||
boolean canBeCancelled,
|
|
||||||
Map<String, String> params,
|
|
||||||
final Consumer<String> callback,
|
|
||||||
final Consumer<Exception> errorCallback) {
|
|
||||||
super(project, title, canBeCancelled);
|
|
||||||
|
|
||||||
myParams = params;
|
|
||||||
myCallback = callback;
|
|
||||||
myErrorCallback = errorCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(@NotNull ProgressIndicator indicator) {
|
|
||||||
indicator.setIndeterminate(true);
|
|
||||||
try {
|
|
||||||
String token = sendFeedback(myParams);
|
|
||||||
myCallback.consume(token);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
myErrorCallback.consume(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getToken() {
|
|
||||||
InputStream stream = GithubFeedbackTask.class.getClassLoader().getResourceAsStream("token");
|
|
||||||
if (stream == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return CharStreams.toString(new InputStreamReader(stream, "UTF-8"));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String sendFeedback(Map<String, String> environmentDetails) throws IOException {
|
|
||||||
String url = "https://api.github.com/repos/JesusFreke/smalidea-issues/issues";
|
|
||||||
String userAgent = "smalidea plugin";
|
|
||||||
|
|
||||||
IdeaPluginDescriptorImpl pluginDescriptor =
|
|
||||||
(IdeaPluginDescriptorImpl) PluginManager.getPlugin(PluginId.getId("org.jf.smalidea"));
|
|
||||||
|
|
||||||
if (pluginDescriptor != null) {
|
|
||||||
String name = pluginDescriptor.getName();
|
|
||||||
String version = pluginDescriptor.getVersion();
|
|
||||||
userAgent = name + " (" + version + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpURLConnection httpURLConnection = connect(url);
|
|
||||||
httpURLConnection.setDoOutput(true);
|
|
||||||
httpURLConnection.setRequestMethod("POST");
|
|
||||||
httpURLConnection.setRequestProperty("User-Agent", userAgent);
|
|
||||||
httpURLConnection.setRequestProperty("Content-Type", "application/json");
|
|
||||||
|
|
||||||
String token = getToken();
|
|
||||||
if (token != null) {
|
|
||||||
httpURLConnection.setRequestProperty("Authorization", "token " + token);
|
|
||||||
}
|
|
||||||
OutputStream outputStream = httpURLConnection.getOutputStream();
|
|
||||||
|
|
||||||
try {
|
|
||||||
outputStream.write(convertToGithubIssueFormat(environmentDetails));
|
|
||||||
} finally {
|
|
||||||
outputStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
int responseCode = httpURLConnection.getResponseCode();
|
|
||||||
if (responseCode != 201) {
|
|
||||||
throw new RuntimeException("Expected HTTP_CREATED (201), obtained " + responseCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Long.toString(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] convertToGithubIssueFormat(Map<String, String> environmentDetails) {
|
|
||||||
LinkedHashMap<String, String> result = new LinkedHashMap<String, String>(5);
|
|
||||||
result.put("title", "[auto-generated] Crash in plugin");
|
|
||||||
result.put("body", generateGithubIssueBody(environmentDetails));
|
|
||||||
|
|
||||||
return ((new Gson()).toJson(result)).getBytes(Charset.forName("UTF-8"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String generateGithubIssueBody(Map<String, String> body) {
|
|
||||||
String errorDescription = body.get("error.description");
|
|
||||||
if (errorDescription == null) {
|
|
||||||
errorDescription = "";
|
|
||||||
}
|
|
||||||
body.remove("error.description");
|
|
||||||
|
|
||||||
String errorMessage = body.get("error.message");
|
|
||||||
if (errorMessage == null || errorMessage.isEmpty()) {
|
|
||||||
errorMessage = "invalid error";
|
|
||||||
}
|
|
||||||
body.remove("error.message");
|
|
||||||
|
|
||||||
String stackTrace = body.get("error.stacktrace");
|
|
||||||
if (stackTrace == null || stackTrace.isEmpty()) {
|
|
||||||
stackTrace = "invalid stacktrace";
|
|
||||||
}
|
|
||||||
body.remove("error.stacktrace");
|
|
||||||
|
|
||||||
String result = "";
|
|
||||||
|
|
||||||
if (!errorDescription.isEmpty()) {
|
|
||||||
result += errorDescription + "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : body.entrySet()) {
|
|
||||||
result += entry.getKey() + ": " + entry.getValue() + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
result += "\n```\n" + stackTrace + "\n```\n";
|
|
||||||
|
|
||||||
result += "\n```\n" + errorMessage + "\n```";
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HttpURLConnection connect(String url) throws IOException {
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) ((new URL(url)).openConnection());
|
|
||||||
connection.setConnectTimeout(5000);
|
|
||||||
connection.setReadTimeout(5000);
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2000-2014 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jf.smalidea.errorReporting;
|
|
||||||
|
|
||||||
import com.intellij.errorreport.bean.ErrorBean;
|
|
||||||
import com.intellij.idea.IdeaLogger;
|
|
||||||
import com.intellij.openapi.application.Application;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
|
||||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
|
||||||
import com.intellij.openapi.diagnostic.Attachment;
|
|
||||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
|
||||||
import com.intellij.util.SystemProperties;
|
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author stathik
|
|
||||||
* @since Aug 4, 2003
|
|
||||||
*/
|
|
||||||
public class ITNProxy {
|
|
||||||
|
|
||||||
public static Map<String, String> createParameters(ErrorBean error) {
|
|
||||||
Map<String, String> params = ContainerUtil.newLinkedHashMap(40);
|
|
||||||
|
|
||||||
params.put("protocol.version", "1");
|
|
||||||
|
|
||||||
params.put("os.name", SystemProperties.getOsName());
|
|
||||||
params.put("java.version", SystemProperties.getJavaVersion());
|
|
||||||
params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
|
|
||||||
|
|
||||||
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
|
|
||||||
ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
|
||||||
Application application = ApplicationManager.getApplication();
|
|
||||||
params.put("app.name", namesInfo.getProductName());
|
|
||||||
params.put("app.name.full", namesInfo.getFullProductName());
|
|
||||||
params.put("app.name.version", appInfo.getVersionName());
|
|
||||||
params.put("app.eap", Boolean.toString(appInfo.isEAP()));
|
|
||||||
params.put("app.internal", Boolean.toString(application.isInternal()));
|
|
||||||
params.put("app.build", appInfo.getBuild().asString());
|
|
||||||
params.put("app.version.major", appInfo.getMajorVersion());
|
|
||||||
params.put("app.version.minor", appInfo.getMinorVersion());
|
|
||||||
params.put("app.build.date", format(appInfo.getBuildDate()));
|
|
||||||
params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
|
|
||||||
params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
|
|
||||||
|
|
||||||
UpdateSettings updateSettings = UpdateSettings.getInstance();
|
|
||||||
params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
|
|
||||||
params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
|
|
||||||
|
|
||||||
params.put("plugin.name", error.getPluginName());
|
|
||||||
params.put("plugin.version", error.getPluginVersion());
|
|
||||||
|
|
||||||
params.put("last.action", error.getLastAction());
|
|
||||||
params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
|
|
||||||
|
|
||||||
params.put("error.message", error.getMessage());
|
|
||||||
params.put("error.stacktrace", error.getStackTrace());
|
|
||||||
params.put("error.description", error.getDescription());
|
|
||||||
|
|
||||||
params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
|
|
||||||
|
|
||||||
for (Attachment attachment : error.getAttachments()) {
|
|
||||||
params.put("attachment.name", attachment.getName());
|
|
||||||
params.put("attachment.value", attachment.getEncodedBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String format(Calendar calendar) {
|
|
||||||
return calendar == null ? null : Long.toString(calendar.getTime().getTime());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.findUsages;
|
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.application.QueryExecutorBase;
|
|
||||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiFile;
|
|
||||||
import com.intellij.psi.PsiReference;
|
|
||||||
import com.intellij.psi.impl.search.LowLevelSearchUtil;
|
|
||||||
import com.intellij.psi.search.*;
|
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch.SearchParameters;
|
|
||||||
import com.intellij.util.Processor;
|
|
||||||
import com.intellij.util.text.StringSearcher;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
public class SmaliClassReferenceSearcher extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
|
|
||||||
@Override public void processQuery(final SearchParameters queryParameters, final Processor<PsiReference> consumer) {
|
|
||||||
final PsiElement element = queryParameters.getElementToSearch();
|
|
||||||
if (!(element instanceof PsiClass)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String smaliType = ApplicationManager.getApplication().runReadAction(
|
|
||||||
new Computable<String>() {
|
|
||||||
@Override public String compute() {
|
|
||||||
String qualifiedName = ((PsiClass)element).getQualifiedName();
|
|
||||||
if (qualifiedName != null) {
|
|
||||||
return NameUtils.javaToSmaliType((PsiClass)element);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (smaliType == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final StringSearcher stringSearcher = new StringSearcher(smaliType, true, true, false, false);
|
|
||||||
|
|
||||||
final SingleTargetRequestResultProcessor processor = new SingleTargetRequestResultProcessor(element);
|
|
||||||
|
|
||||||
SearchScope querySearchScope = ApplicationManager.getApplication().runReadAction(
|
|
||||||
new Computable<SearchScope>() {
|
|
||||||
@Override public SearchScope compute() {
|
|
||||||
return queryParameters.getEffectiveSearchScope();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (querySearchScope instanceof LocalSearchScope) {
|
|
||||||
for (final PsiElement scopeElement : ((LocalSearchScope)querySearchScope).getScope()) {
|
|
||||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
LowLevelSearchUtil.processElementsContainingWordInElement(
|
|
||||||
new TextOccurenceProcessor() {
|
|
||||||
@Override public boolean execute(
|
|
||||||
@NotNull PsiElement element, int offsetInElement) {
|
|
||||||
return processor.processTextOccurrence(element, offsetInElement, consumer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scopeElement, stringSearcher, true, new EmptyProgressIndicator());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (querySearchScope instanceof GlobalSearchScope) {
|
|
||||||
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
|
|
||||||
// TODO: limit search scope to only smali files. See, e.g. AnnotatedPackagesSearcher.PackageInfoFilesOnly
|
|
||||||
helper.processAllFilesWithWord(smaliType, (GlobalSearchScope)querySearchScope,
|
|
||||||
new Processor<PsiFile>() {
|
|
||||||
@Override
|
|
||||||
public boolean process(PsiFile file) {
|
|
||||||
LowLevelSearchUtil.processElementsContainingWordInElement(
|
|
||||||
new TextOccurenceProcessor() {
|
|
||||||
@Override public boolean execute(
|
|
||||||
@NotNull PsiElement element, int offsetInElement) {
|
|
||||||
return processor.processTextOccurrence(element, offsetInElement, consumer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
file, stringSearcher, true, new EmptyProgressIndicator());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
} else {
|
|
||||||
assert false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.findUsages;
|
|
||||||
|
|
||||||
import com.intellij.lang.cacheBuilder.WordsScanner;
|
|
||||||
import com.intellij.lang.java.JavaFindUsagesProvider;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class SmaliFindUsagesProvider extends JavaFindUsagesProvider {
|
|
||||||
@Override public boolean canFindUsagesFor(@NotNull PsiElement element) {
|
|
||||||
return element instanceof PsiClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public WordsScanner getWordsScanner() {
|
|
||||||
return new SmaliWordScanner();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.findUsages;
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
|
||||||
import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter;
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.openapi.editor.Editor;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiFile;
|
|
||||||
import com.intellij.usages.UsageTarget;
|
|
||||||
import com.intellij.usages.UsageTargetProvider;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.SmaliTokens;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliMemberName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A usage target provider for smali member names consisting of primitive types.
|
|
||||||
*
|
|
||||||
* For member names like IIII, the default logic to find the usage target doesn't work, due to the member
|
|
||||||
* name being split up into multiple leaf tokens.
|
|
||||||
*/
|
|
||||||
public class SmaliUsageTargetProvider implements UsageTargetProvider {
|
|
||||||
@Nullable @Override public UsageTarget[] getTargets(Editor editor, PsiFile file) {
|
|
||||||
PsiElement element = file.findElementAt(
|
|
||||||
TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()));
|
|
||||||
if (element == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getTargets(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public UsageTarget[] getTargets(PsiElement element) {
|
|
||||||
ASTNode node = element.getNode();
|
|
||||||
if (node == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.getElementType() == SmaliTokens.PARAM_LIST_OR_ID_PRIMITIVE_TYPE) {
|
|
||||||
PsiElement parent = element.getParent();
|
|
||||||
if (parent instanceof SmaliMemberName) {
|
|
||||||
return new UsageTarget[] { new PsiElement2UsageTargetAdapter(parent.getParent()) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,200 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.findUsages;
|
|
||||||
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import com.intellij.usages.impl.rules.UsageType;
|
|
||||||
import com.intellij.usages.impl.rules.UsageTypeProvider;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.dexlib2.Opcode;
|
|
||||||
import org.jf.smalidea.SmaliTokens;
|
|
||||||
import org.jf.smalidea.psi.impl.*;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SmaliUsageTypeProvider implements UsageTypeProvider {
|
|
||||||
|
|
||||||
static final UsageType CLASS_DECLARATION = new UsageType("Class declaration");
|
|
||||||
static final UsageType VERIFICATION_ERROR = new UsageType("Usage in verification error");
|
|
||||||
static final UsageType FIELD_TYPE_REFERENCE = new UsageType("Usage as field type in a field reference");
|
|
||||||
static final UsageType FIELD_DECLARING_TYPE_REFERENCE = new UsageType("Usage as a declaring type in a field reference");
|
|
||||||
static final UsageType METHOD_RETURN_TYPE_REFERENCE = new UsageType("Usage as return type in a method reference");
|
|
||||||
static final UsageType METHOD_PARAM_REFERENCE = new UsageType("Usage as parameter in a method reference");
|
|
||||||
static final UsageType METHOD_DECLARING_TYPE_REFERENCE = new UsageType("Usage as a declaring type in a method reference");
|
|
||||||
static final UsageType LITERAL = new UsageType("Usage as a literal");
|
|
||||||
|
|
||||||
@Nullable @Override public UsageType getUsageType(PsiElement element) {
|
|
||||||
if (element instanceof PsiReference) {
|
|
||||||
PsiElement referenced = ((PsiReference) element).resolve();
|
|
||||||
if (referenced != null) {
|
|
||||||
if (referenced instanceof PsiClass) {
|
|
||||||
return findClassUsageType(element);
|
|
||||||
} else if (referenced instanceof PsiField) {
|
|
||||||
return findFieldUsageType(element);
|
|
||||||
} else if (referenced instanceof PsiMethod) {
|
|
||||||
return findMethodUsageType(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UsageType.UNCLASSIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Set<Opcode> newArrayInstructions = EnumSet.of(Opcode.FILLED_NEW_ARRAY, Opcode.NEW_ARRAY,
|
|
||||||
Opcode.FILLED_NEW_ARRAY_RANGE);
|
|
||||||
|
|
||||||
private final Set<Opcode> fieldReadInstructions = EnumSet.of(Opcode.IGET, Opcode.IGET_BOOLEAN, Opcode.IGET_BYTE,
|
|
||||||
Opcode.IGET_CHAR, Opcode.IGET_OBJECT, Opcode.IGET_OBJECT_VOLATILE, Opcode.IGET_SHORT, Opcode.IGET_VOLATILE,
|
|
||||||
Opcode.IGET_WIDE, Opcode.IGET_WIDE_VOLATILE, Opcode.SGET, Opcode.SGET_BOOLEAN, Opcode.SGET_BYTE,
|
|
||||||
Opcode.SGET_CHAR, Opcode.SGET_OBJECT, Opcode.SGET_OBJECT_VOLATILE, Opcode.SGET_SHORT, Opcode.SGET_VOLATILE,
|
|
||||||
Opcode.SGET_WIDE, Opcode.SGET_WIDE_VOLATILE);
|
|
||||||
|
|
||||||
private final Set<Opcode> fieldWriteInstructions = EnumSet.of(Opcode.IPUT, Opcode.IPUT_BOOLEAN, Opcode.IPUT_BYTE,
|
|
||||||
Opcode.IPUT_CHAR, Opcode.IPUT_OBJECT, Opcode.IPUT_OBJECT_VOLATILE, Opcode.IPUT_SHORT, Opcode.IPUT_VOLATILE,
|
|
||||||
Opcode.IPUT_WIDE, Opcode.IPUT_WIDE_VOLATILE, Opcode.SPUT, Opcode.SPUT_BOOLEAN, Opcode.SPUT_BYTE,
|
|
||||||
Opcode.SPUT_CHAR, Opcode.SPUT_OBJECT, Opcode.SPUT_OBJECT_VOLATILE, Opcode.SPUT_SHORT, Opcode.SPUT_VOLATILE,
|
|
||||||
Opcode.SPUT_WIDE, Opcode.SPUT_WIDE_VOLATILE);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private UsageType findClassUsageType(@NotNull PsiElement element) {
|
|
||||||
PsiElement originalElement = element;
|
|
||||||
|
|
||||||
while (element != null) {
|
|
||||||
if (element instanceof SmaliFieldReference) {
|
|
||||||
PsiElement prev = originalElement.getPrevSibling();
|
|
||||||
while (prev != null) {
|
|
||||||
// if the element is to the right of a colon, then it is the field type, otherwise it is
|
|
||||||
// the declaring class
|
|
||||||
if (prev.getNode().getElementType() == SmaliTokens.COLON) {
|
|
||||||
return FIELD_TYPE_REFERENCE;
|
|
||||||
}
|
|
||||||
prev = prev.getPrevSibling();
|
|
||||||
}
|
|
||||||
return FIELD_DECLARING_TYPE_REFERENCE;
|
|
||||||
} else if (element instanceof SmaliMethodReferenceParamList) {
|
|
||||||
return METHOD_PARAM_REFERENCE;
|
|
||||||
} else if (element instanceof SmaliMethodReference) {
|
|
||||||
PsiElement prev = originalElement.getPrevSibling();
|
|
||||||
while (prev != null) {
|
|
||||||
IElementType elementType = prev.getNode().getElementType();
|
|
||||||
// if the element is to the right of a close paren, then it is the return type,
|
|
||||||
// otherwise it is the declaring class. Any parameter type will be taken care of by the previous
|
|
||||||
// "if" for SmaliMethodReferenceParamList
|
|
||||||
if (elementType == SmaliTokens.CLOSE_PAREN) {
|
|
||||||
return METHOD_RETURN_TYPE_REFERENCE;
|
|
||||||
}
|
|
||||||
prev = prev.getPrevSibling();
|
|
||||||
}
|
|
||||||
return METHOD_DECLARING_TYPE_REFERENCE;
|
|
||||||
} else if (element instanceof SmaliInstruction) {
|
|
||||||
Opcode opcode = ((SmaliInstruction) element).getOpcode();
|
|
||||||
if (opcode == Opcode.INSTANCE_OF) {
|
|
||||||
return UsageType.CLASS_INSTANCE_OF;
|
|
||||||
} else if (opcode == Opcode.CHECK_CAST) {
|
|
||||||
return UsageType.CLASS_CAST_TO;
|
|
||||||
} else if (newArrayInstructions.contains(opcode)) {
|
|
||||||
return UsageType.CLASS_NEW_ARRAY;
|
|
||||||
} else if (opcode == Opcode.NEW_INSTANCE) {
|
|
||||||
return UsageType.CLASS_NEW_OPERATOR;
|
|
||||||
} else if (opcode == Opcode.CONST_CLASS) {
|
|
||||||
return UsageType.CLASS_CLASS_OBJECT_ACCESS;
|
|
||||||
} else if (opcode == Opcode.THROW_VERIFICATION_ERROR) {
|
|
||||||
return VERIFICATION_ERROR;
|
|
||||||
}
|
|
||||||
} else if (element instanceof SmaliSuperStatement || element instanceof SmaliImplementsStatement) {
|
|
||||||
return UsageType.CLASS_EXTENDS_IMPLEMENTS_LIST;
|
|
||||||
} else if (element instanceof SmaliClassStatement) {
|
|
||||||
return CLASS_DECLARATION;
|
|
||||||
} else if (element instanceof SmaliMethodParamList) {
|
|
||||||
return UsageType.CLASS_METHOD_PARAMETER_DECLARATION;
|
|
||||||
} else if (element instanceof SmaliMethodPrototype) {
|
|
||||||
return UsageType.CLASS_METHOD_RETURN_TYPE;
|
|
||||||
} else if (element instanceof SmaliField) {
|
|
||||||
return UsageType.CLASS_FIELD_DECLARATION;
|
|
||||||
} else if (element instanceof SmaliCatchStatement) {
|
|
||||||
return UsageType.CLASS_CATCH_CLAUSE_PARAMETER_DECLARATION;
|
|
||||||
} else if (element instanceof SmaliLocalDebugStatement) {
|
|
||||||
return UsageType.CLASS_LOCAL_VAR_DECLARATION;
|
|
||||||
} else if (element instanceof SmaliAnnotation) {
|
|
||||||
return UsageType.ANNOTATION;
|
|
||||||
} else if (element instanceof SmaliLiteral) {
|
|
||||||
return LITERAL;
|
|
||||||
}
|
|
||||||
element = element.getParent();
|
|
||||||
}
|
|
||||||
return UsageType.UNCLASSIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private UsageType findFieldUsageType(@NotNull PsiElement element) {
|
|
||||||
PsiElement originalElement = element;
|
|
||||||
|
|
||||||
while (element != null) {
|
|
||||||
element = element.getParent();
|
|
||||||
|
|
||||||
if (element instanceof SmaliInstruction) {
|
|
||||||
Opcode opcode = ((SmaliInstruction) element).getOpcode();
|
|
||||||
if (fieldReadInstructions.contains(opcode)) {
|
|
||||||
return UsageType.READ;
|
|
||||||
} else if (fieldWriteInstructions.contains(opcode)) {
|
|
||||||
return UsageType.WRITE;
|
|
||||||
} else if (opcode == Opcode.THROW_VERIFICATION_ERROR) {
|
|
||||||
return VERIFICATION_ERROR;
|
|
||||||
}
|
|
||||||
} if (element instanceof SmaliLiteral) {
|
|
||||||
return LITERAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UsageType.UNCLASSIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private UsageType findMethodUsageType(@NotNull PsiElement element) {
|
|
||||||
PsiElement originalElement = element;
|
|
||||||
|
|
||||||
while (element != null) {
|
|
||||||
element = element.getParent();
|
|
||||||
|
|
||||||
if (element instanceof SmaliInstruction) {
|
|
||||||
Opcode opcode = ((SmaliInstruction) element).getOpcode();
|
|
||||||
if (opcode == Opcode.THROW_VERIFICATION_ERROR) {
|
|
||||||
return VERIFICATION_ERROR;
|
|
||||||
}
|
|
||||||
} if (element instanceof SmaliLiteral) {
|
|
||||||
return LITERAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UsageType.UNCLASSIFIED;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.findUsages;
|
|
||||||
|
|
||||||
import com.intellij.lang.cacheBuilder.WordOccurrence;
|
|
||||||
import com.intellij.lang.cacheBuilder.WordOccurrence.Kind;
|
|
||||||
import com.intellij.lang.cacheBuilder.WordsScanner;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import com.intellij.psi.tree.TokenSet;
|
|
||||||
import com.intellij.util.Processor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.SmaliLexer;
|
|
||||||
import org.jf.smalidea.SmaliTokens;
|
|
||||||
|
|
||||||
public class SmaliWordScanner implements WordsScanner {
|
|
||||||
|
|
||||||
private static final TokenSet MEMBER_NAME_TOKENS = TokenSet.create(
|
|
||||||
SmaliTokens.MEMBER_NAME,
|
|
||||||
SmaliTokens.SIMPLE_NAME,
|
|
||||||
SmaliTokens.ACCESS_SPEC,
|
|
||||||
SmaliTokens.VERIFICATION_ERROR_TYPE,
|
|
||||||
SmaliTokens.POSITIVE_INTEGER_LITERAL,
|
|
||||||
SmaliTokens.NEGATIVE_INTEGER_LITERAL,
|
|
||||||
SmaliTokens.FLOAT_LITERAL_OR_ID,
|
|
||||||
SmaliTokens.DOUBLE_LITERAL_OR_ID,
|
|
||||||
SmaliTokens.BOOL_LITERAL,
|
|
||||||
SmaliTokens.NULL_LITERAL,
|
|
||||||
SmaliTokens.REGISTER,
|
|
||||||
SmaliTokens.PRIMITIVE_TYPE,
|
|
||||||
SmaliTokens.VOID_TYPE,
|
|
||||||
SmaliTokens.ANNOTATION_VISIBILITY,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT10t,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT10x,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT10x_ODEX,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT11x,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT12x_OR_ID,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT21c_FIELD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT21c_FIELD_ODEX,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT21c_STRING,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT21c_TYPE,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT21t,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22c_FIELD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22c_FIELD_ODEX,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22c_TYPE,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22cs_FIELD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22s_OR_ID,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT22t,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT23x,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT31i_OR_ID,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT31t,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT35c_METHOD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT35c_METHOD_ODEX,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT35c_TYPE,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT35mi_METHOD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT35ms_METHOD,
|
|
||||||
SmaliTokens.INSTRUCTION_FORMAT51l);
|
|
||||||
|
|
||||||
@Override public void processWords(CharSequence fileText, Processor<WordOccurrence> processor) {
|
|
||||||
SmaliLexer lexer = new SmaliLexer();
|
|
||||||
lexer.start(fileText);
|
|
||||||
|
|
||||||
IElementType type = lexer.getTokenType();
|
|
||||||
while (type != null) {
|
|
||||||
if (type == SmaliTokens.CLASS_DESCRIPTOR) {
|
|
||||||
processClassDescriptor(fileText, lexer.getTokenStart(), lexer.getTokenEnd(), processor);
|
|
||||||
} else if (MEMBER_NAME_TOKENS.contains(type)) {
|
|
||||||
processor.process(new WordOccurrence(fileText, lexer.getTokenStart(), lexer.getTokenEnd(), Kind.CODE));
|
|
||||||
} else if (type == SmaliTokens.PARAM_LIST_OR_ID_PRIMITIVE_TYPE) {
|
|
||||||
int tokenStart = lexer.getTokenStart();
|
|
||||||
while (type == SmaliTokens.PARAM_LIST_OR_ID_PRIMITIVE_TYPE) {
|
|
||||||
lexer.advance();
|
|
||||||
type = lexer.getTokenType();
|
|
||||||
}
|
|
||||||
int tokenEnd = lexer.getTokenStart();
|
|
||||||
processor.process(new WordOccurrence(fileText, tokenStart, tokenEnd, Kind.CODE));
|
|
||||||
}
|
|
||||||
lexer.advance();
|
|
||||||
type = lexer.getTokenType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processClassDescriptor(CharSequence fileText, int tokenStart, int tokenEnd,
|
|
||||||
@NotNull Processor<WordOccurrence> processor) {
|
|
||||||
CharSequence tokenText = fileText.subSequence(tokenStart, tokenEnd);
|
|
||||||
|
|
||||||
assert tokenText.charAt(0) == 'L' && tokenText.charAt(tokenText.length()-1) == ';';
|
|
||||||
processor.process(new WordOccurrence(fileText, tokenStart, tokenEnd, Kind.CODE));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi;
|
|
||||||
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliCompositeElement;
|
|
||||||
|
|
||||||
public interface SmaliCompositeElementFactory {
|
|
||||||
SmaliCompositeElement createElement();
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi;
|
|
||||||
|
|
||||||
import com.intellij.psi.tree.ICompositeElementType;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import org.jetbrains.annotations.NonNls;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.SmaliLanguage;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliCompositeElement;
|
|
||||||
|
|
||||||
public class SmaliCompositeElementType extends IElementType implements ICompositeElementType {
|
|
||||||
@NotNull private final SmaliCompositeElementFactory factory;
|
|
||||||
|
|
||||||
public SmaliCompositeElementType(@NotNull @NonNls String debugName,
|
|
||||||
@NotNull SmaliCompositeElementFactory factory) {
|
|
||||||
super(debugName, SmaliLanguage.INSTANCE);
|
|
||||||
this.factory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public SmaliCompositeElement createCompositeNode() {
|
|
||||||
return factory.createElement();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi;
|
|
||||||
|
|
||||||
import org.jf.smalidea.psi.impl.*;
|
|
||||||
import org.jf.smalidea.psi.stub.element.*;
|
|
||||||
|
|
||||||
public class SmaliElementTypes {
|
|
||||||
public static final SmaliFileElementType FILE = SmaliFileElementType.INSTANCE;
|
|
||||||
public static final SmaliClassElementType CLASS = SmaliClassElementType.INSTANCE;
|
|
||||||
public static final SmaliFieldElementType FIELD = SmaliFieldElementType.INSTANCE;
|
|
||||||
public static final SmaliMethodElementType METHOD = SmaliMethodElementType.INSTANCE;
|
|
||||||
public static final SmaliClassStatementElementType CLASS_STATEMENT = SmaliClassStatementElementType.INSTANCE;
|
|
||||||
public static final SmaliMethodPrototypeElementType METHOD_PROTOTYPE = SmaliMethodPrototypeElementType.INSTANCE;
|
|
||||||
public static final SmaliMethodParamListElementType METHOD_PARAM_LIST = SmaliMethodParamListElementType.INSTANCE;
|
|
||||||
public static final SmaliMethodParameterElementType METHOD_PARAMETER = SmaliMethodParameterElementType.INSTANCE;
|
|
||||||
public static final SmaliAnnotationElementType ANNOTATION = SmaliAnnotationElementType.INSTANCE;
|
|
||||||
public static final SmaliModifierListElementType MODIFIER_LIST = SmaliModifierListElementType.INSTANCE;
|
|
||||||
public static final SmaliExtendsListElementType EXTENDS_LIST = SmaliExtendsListElementType.INSTANCE;
|
|
||||||
public static final SmaliImplementsListElementType IMPLEMENTS_LIST = SmaliImplementsListElementType.INSTANCE;
|
|
||||||
public static final SmaliThrowsListElementType THROWS_LIST = SmaliThrowsListElementType.INSTANCE;
|
|
||||||
|
|
||||||
public static final SmaliCompositeElementType LITERAL =
|
|
||||||
new SmaliCompositeElementType("LITERAL", SmaliLiteral.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType SUPER_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("SUPER_STATEMENT", SmaliSuperStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType IMPLEMENTS_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("IMPLEMENTS_STATEMENT", SmaliImplementsStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType SOURCE_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("SOURCE_STATEMENT", SmaliSourceStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType REGISTERS_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("REGISTERS_STATEMENT", SmaliRegistersStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType REGISTER_REFERENCE =
|
|
||||||
new SmaliCompositeElementType("REGISTER_REFERENCE", SmaliRegisterReference.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType MEMBER_NAME =
|
|
||||||
new SmaliCompositeElementType("MEMBER_NAME", SmaliMemberName.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType LOCAL_NAME =
|
|
||||||
new SmaliCompositeElementType("LOCAL_NAME", SmaliLocalName.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType PARAMETER_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("PARAMETER_STATEMENT", SmaliParameterStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType FIELD_INITIALIZER =
|
|
||||||
new SmaliCompositeElementType("FIELD_INITIALIZER", SmaliFieldInitializer.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType INSTRUCTION =
|
|
||||||
new SmaliCompositeElementType("INSTRUCTION", SmaliInstruction.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType ANNOTATION_PARAMETER_LIST =
|
|
||||||
new SmaliCompositeElementType("ANNOTATION_PARAMETER_LIST", SmaliAnnotationParameterList.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType ANNOTATION_ELEMENT =
|
|
||||||
new SmaliCompositeElementType("ANNOTATION_ELEMENT", SmaliAnnotationElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType ANNOTATION_ELEMENT_NAME =
|
|
||||||
new SmaliCompositeElementType("ANNOTATION_ELEMENT_NAME", SmaliAnnotationElementName.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType FIELD_REFERENCE =
|
|
||||||
new SmaliCompositeElementType("FIELD_REFERENCE", SmaliFieldReference.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType METHOD_REFERENCE =
|
|
||||||
new SmaliCompositeElementType("METHOD_REFERENCE", SmaliMethodReference.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType METHOD_REFERENCE_PARAM_LIST =
|
|
||||||
new SmaliCompositeElementType("METHOD_REFERENCE_PARAM_LIST", SmaliMethodReferenceParamList.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType LABEL =
|
|
||||||
new SmaliCompositeElementType("LABEL", SmaliLabel.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType LABEL_REFERENCE =
|
|
||||||
new SmaliCompositeElementType("LABEL_REFERENCE", SmaliLabelReference.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType LINE_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("LINE_DEBUG_STATEMENT", SmaliLineDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType LOCAL_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("LOCAL_DEBUG_STATEMENT", SmaliLocalDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType END_LOCAL_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("END_LOCAL_DEBUG_STATEMENT", SmaliEndLocalDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType RESTART_LOCAL_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("RESTART_LOCAL_DEBUG_STATEMENT", SmaliRestartLocalDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType PROLOGUE_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("PROLOGUE_DEBUG_STATEMENT", SmaliPrologueDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType EPILOGUE_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("EPILOGUE_DEBUG_STATEMENT", SmaliEpilogueDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType SOURCE_DEBUG_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("SOURCE_DEBUG_STATEMENT", SmaliSourceDebugStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType PRIMITIVE_TYPE =
|
|
||||||
new SmaliCompositeElementType("PRIMITIVE_TYPE", SmaliPrimitiveTypeElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType CLASS_TYPE =
|
|
||||||
new SmaliCompositeElementType("CLASS_TYPE", SmaliClassTypeElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType ARRAY_TYPE =
|
|
||||||
new SmaliCompositeElementType("ARRAY_TYPE", SmaliArrayTypeElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType VOID_TYPE =
|
|
||||||
new SmaliCompositeElementType("VOID_TYPE", SmaliVoidTypeElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType CATCH_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("CATCH_STATEMENT", SmaliCatchStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType CATCH_ALL_STATEMENT =
|
|
||||||
new SmaliCompositeElementType("CATCH_ALL_STATEMENT", SmaliCatchAllStatement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType PACKED_SWITCH_ELEMENT =
|
|
||||||
new SmaliCompositeElementType("PACKED_SWITCH_ELEMENT", SmaliPackedSwitchElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType SPARSE_SWITCH_ELEMENT =
|
|
||||||
new SmaliCompositeElementType("SPARSE_SWITCH_ELEMENT", SmaliSparseSwitchElement.FACTORY);
|
|
||||||
public static final SmaliCompositeElementType ARRAY_DATA_ELEMENT =
|
|
||||||
new SmaliCompositeElementType("ARRAY_DATA_ELEMENT", SmaliArrayDataElement.FACTORY);
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.iface;
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotationOwner;
|
|
||||||
import com.intellij.psi.PsiModifierListOwner;
|
|
||||||
import org.jetbrains.annotations.NonNls;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliAnnotation;
|
|
||||||
import org.jf.smalidea.psi.impl.SmaliModifierList;
|
|
||||||
|
|
||||||
public interface SmaliModifierListOwner extends PsiModifierListOwner, PsiAnnotationOwner {
|
|
||||||
@NotNull @Override SmaliAnnotation[] getAnnotations();
|
|
||||||
@NotNull @Override SmaliAnnotation[] getApplicableAnnotations();
|
|
||||||
@Nullable @Override SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName);
|
|
||||||
@NotNull @Override SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName);
|
|
||||||
@Nullable @Override SmaliModifierList getModifierList();
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.TextRange;
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.impl.light.LightElement;
|
|
||||||
import com.intellij.psi.infos.CandidateInfo;
|
|
||||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
|
||||||
import com.intellij.util.IncorrectOperationException;
|
|
||||||
import org.jetbrains.annotations.NonNls;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.SmaliLanguage;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
public class LightSmaliClassTypeElement extends LightElement
|
|
||||||
implements PsiTypeElement, PsiReference, PsiJavaCodeReferenceElement {
|
|
||||||
@NotNull
|
|
||||||
private final String smaliName;
|
|
||||||
|
|
||||||
public LightSmaliClassTypeElement(@NotNull PsiManager manager, @NotNull String smaliName) {
|
|
||||||
super(manager, SmaliLanguage.INSTANCE);
|
|
||||||
this.smaliName = smaliName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return "LightSmaliClassTypeElement:" + smaliName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiType getType() {
|
|
||||||
return new SmaliClassType(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public LightSmaliClassTypeElement getInnermostComponentReferenceElement() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getText() {
|
|
||||||
return smaliName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiReference getReference() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement getElement() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public TextRange getRangeInElement() {
|
|
||||||
return new TextRange(0, getTextLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiClass resolve() {
|
|
||||||
return NameUtils.resolveSmaliType(this, smaliName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getCanonicalText() {
|
|
||||||
return NameUtils.resolveSmaliToJavaType(this, smaliName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isReferenceTo(PsiElement element) {
|
|
||||||
if (!(element instanceof PsiClassType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return element.getManager().areElementsEquivalent(element, resolve());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public Object[] getVariants() {
|
|
||||||
throw new RuntimeException("Variants are not available for light references");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isSoft() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiAnnotation[] getAnnotations() {
|
|
||||||
return new PsiAnnotation[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiAnnotation[] getApplicableAnnotations() {
|
|
||||||
return new PsiAnnotation[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
// Below are the PsiJavaCodeReferenceElement-specific methods
|
|
||||||
|
|
||||||
@Override public void processVariants(@NotNull PsiScopeProcessor processor) {
|
|
||||||
// TODO: maybe just do nothing?
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiElement getReferenceNameElement() {
|
|
||||||
// TODO: implement if needed
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiReferenceParameterList getParameterList() {
|
|
||||||
// TODO: (generics) implement this
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiType[] getTypeParameters() {
|
|
||||||
// TODO: (generics) implement this
|
|
||||||
return new PsiType[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isQualified() {
|
|
||||||
// TODO: should this return false for classes in the top level package?
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getQualifiedName() {
|
|
||||||
return getCanonicalText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public JavaResolveResult advancedResolve(boolean incompleteCode) {
|
|
||||||
PsiClass element = resolve();
|
|
||||||
if (element == null) {
|
|
||||||
return JavaResolveResult.EMPTY;
|
|
||||||
}
|
|
||||||
return new CandidateInfo(element, PsiSubstitutor.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public JavaResolveResult[] multiResolve(boolean incompleteCode) {
|
|
||||||
PsiClass element = resolve();
|
|
||||||
if (element == null) {
|
|
||||||
return JavaResolveResult.EMPTY_ARRAY;
|
|
||||||
}
|
|
||||||
return new CandidateInfo[] { new CandidateInfo(element, PsiSubstitutor.EMPTY) };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiElement getQualifier() {
|
|
||||||
// TODO: implement this if needed
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getReferenceName() {
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.impl.PsiImplUtil;
|
|
||||||
import com.intellij.psi.meta.PsiMetaData;
|
|
||||||
import org.jetbrains.annotations.NonNls;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
import org.jf.smalidea.psi.stub.SmaliAnnotationStub;
|
|
||||||
|
|
||||||
public class SmaliAnnotation extends SmaliStubBasedPsiElement<SmaliAnnotationStub> implements PsiAnnotation {
|
|
||||||
public SmaliAnnotation(@NotNull SmaliAnnotationStub stub) {
|
|
||||||
super(stub, SmaliElementTypes.ANNOTATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SmaliAnnotation(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public SmaliAnnotationParameterList getParameterList() {
|
|
||||||
SmaliAnnotationParameterList paramList = findChildByClass(SmaliAnnotationParameterList.class);
|
|
||||||
// The structure of the parser should ensure the param list is always present, even if there are syntax errors
|
|
||||||
assert paramList != null;
|
|
||||||
return paramList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getQualifiedName() {
|
|
||||||
PsiJavaCodeReferenceElement nameElement = getNameReferenceElement();
|
|
||||||
if (nameElement != null) {
|
|
||||||
return nameElement.getQualifiedName();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable public String getSmaliName() {
|
|
||||||
SmaliAnnotationStub stub = getStub();
|
|
||||||
if (stub != null) {
|
|
||||||
return stub.getAnnotationSmaliTypeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliClassTypeElement classType = findChildByClass(SmaliClassTypeElement.class);
|
|
||||||
if (classType == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return classType.getSmaliName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiJavaCodeReferenceElement getNameReferenceElement() {
|
|
||||||
SmaliAnnotationStub stub = getStub();
|
|
||||||
if (stub != null) {
|
|
||||||
String smaliName = stub.getAnnotationSmaliTypeName();
|
|
||||||
if (smaliName != null) {
|
|
||||||
return new LightSmaliClassTypeElement(getManager(), smaliName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return findChildByClass(SmaliClassTypeElement.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiAnnotationMemberValue findAttributeValue(@Nullable @NonNls String attributeName) {
|
|
||||||
return PsiImplUtil.findAttributeValue(this, attributeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override
|
|
||||||
public PsiAnnotationMemberValue findDeclaredAttributeValue(@Nullable @NonNls String attributeName) {
|
|
||||||
return PsiImplUtil.findDeclaredAttributeValue(this, attributeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends PsiAnnotationMemberValue> T setDeclaredAttributeValue(
|
|
||||||
@Nullable @NonNls String attributeName, @Nullable T value) {
|
|
||||||
// TODO: implement this
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiAnnotationOwner getOwner() {
|
|
||||||
return (PsiAnnotationOwner)getParentByStub();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiMetaData getMetaData() {
|
|
||||||
// I have no idea what this is
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.psi.PsiAnnotationMemberValue;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiNameValuePair;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.SmaliTokens;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliAnnotationElement extends SmaliCompositeElement implements PsiNameValuePair {
|
|
||||||
// TODO: consider making this a stub
|
|
||||||
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliAnnotationElement();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliAnnotationElement() {
|
|
||||||
super(SmaliElementTypes.ANNOTATION_ELEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getName() {
|
|
||||||
SmaliAnnotationElementName identifier = getNameIdentifier();
|
|
||||||
if (identifier != null) {
|
|
||||||
return identifier.getName();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public SmaliAnnotationElementName getNameIdentifier() {
|
|
||||||
return findChildByClass(SmaliAnnotationElementName.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiAnnotationMemberValue getValue() {
|
|
||||||
ASTNode equalNode = findChildByType(SmaliTokens.EQUAL);
|
|
||||||
if (equalNode == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
PsiElement nextElement = equalNode.getPsi().getNextSibling();
|
|
||||||
while (nextElement != null) {
|
|
||||||
if (nextElement instanceof PsiAnnotationMemberValue) {
|
|
||||||
return (PsiAnnotationMemberValue)nextElement;
|
|
||||||
}
|
|
||||||
nextElement = nextElement.getNextSibling();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiAnnotationMemberValue setValue(@NotNull PsiAnnotationMemberValue newValue) {
|
|
||||||
// TODO: implement this
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getLiteralValue() {
|
|
||||||
// Not applicable for smali
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.TextRange;
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
|
||||||
import com.intellij.util.ArrayUtil;
|
|
||||||
import com.intellij.util.IncorrectOperationException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliAnnotationElementName extends SmaliCompositeElement implements PsiIdentifier, PsiReference {
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliAnnotationElementName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliAnnotationElementName() {
|
|
||||||
super(SmaliElementTypes.ANNOTATION_ELEMENT_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public IElementType getTokenType() {
|
|
||||||
return getElementType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getName() {
|
|
||||||
return getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public SmaliAnnotation getContainingAnnotation() {
|
|
||||||
return findAncestorByClass(SmaliAnnotation.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement bindToElement(PsiElement element) throws IncorrectOperationException {
|
|
||||||
//TODO: implement this if needed
|
|
||||||
throw new IncorrectOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement getElement() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public TextRange getRangeInElement() {
|
|
||||||
return new TextRange(0, getTextLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public PsiElement resolve() {
|
|
||||||
SmaliAnnotation smaliAnnotation = getContainingAnnotation();
|
|
||||||
if (smaliAnnotation == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String annotationType = smaliAnnotation.getQualifiedName();
|
|
||||||
if (annotationType == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
|
||||||
PsiClass annotationClass = facade.findClass(annotationType, getResolveScope());
|
|
||||||
if (annotationClass == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PsiMethod method : annotationClass.findMethodsByName(getName(), true)) {
|
|
||||||
if (method.getParameterList().getParametersCount() == 0) {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public String getCanonicalText() {
|
|
||||||
// TODO: return a full method reference here?
|
|
||||||
String name = getName();
|
|
||||||
if (name == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
|
|
||||||
//TODO: implement this
|
|
||||||
throw new IncorrectOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isReferenceTo(PsiElement element) {
|
|
||||||
return resolve() == element;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public Object[] getVariants() {
|
|
||||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isSoft() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PsiReference getReference() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotationParameterList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliAnnotationParameterList extends SmaliCompositeElement implements PsiAnnotationParameterList {
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliAnnotationParameterList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliAnnotationParameterList() {
|
|
||||||
super(SmaliElementTypes.ANNOTATION_PARAMETER_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public SmaliAnnotationElement[] getAttributes() {
|
|
||||||
return findChildrenByClass(SmaliAnnotationElement.class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliArrayDataElement extends SmaliCompositeElement {
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliArrayDataElement();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliArrayDataElement() {
|
|
||||||
super(SmaliElementTypes.ARRAY_DATA_ELEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public SmaliLiteral getValue() {
|
|
||||||
return findChildByClass(SmaliLiteral.class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.psi.PsiArrayType;
|
|
||||||
import com.intellij.psi.PsiType;
|
|
||||||
import com.intellij.psi.PsiTypeElement;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.SmaliTokens;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliArrayTypeElement extends SmaliTypeElement {
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliArrayTypeElement();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliArrayTypeElement() {
|
|
||||||
super(SmaliElementTypes.ARRAY_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public PsiType getType() {
|
|
||||||
ASTNode token = findChildByType(SmaliTokens.ARRAY_TYPE_PREFIX);
|
|
||||||
assert token != null;
|
|
||||||
PsiTypeElement baseType = findChildByClass(PsiTypeElement.class);
|
|
||||||
assert baseType != null;
|
|
||||||
|
|
||||||
PsiArrayType arrayType = new PsiArrayType(baseType.getType());
|
|
||||||
int dimensions = token.getTextLength() - 1;
|
|
||||||
while (dimensions > 0) {
|
|
||||||
arrayType = new PsiArrayType(arrayType);
|
|
||||||
dimensions--;
|
|
||||||
}
|
|
||||||
return arrayType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public SmaliClassTypeElement getInnermostComponentReferenceElement() {
|
|
||||||
return findChildByClass(SmaliClassTypeElement.class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import com.intellij.psi.PsiReferenceList;
|
|
||||||
import com.intellij.psi.StubBasedPsiElement;
|
|
||||||
import com.intellij.psi.stubs.IStubElementType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jf.smalidea.psi.stub.SmaliBaseReferenceListStub;
|
|
||||||
import org.jf.smalidea.util.NameUtils;
|
|
||||||
|
|
||||||
public abstract class SmaliBaseReferenceList<StubT extends SmaliBaseReferenceListStub>
|
|
||||||
extends SmaliStubBasedPsiElement<StubT> implements StubBasedPsiElement<StubT>, PsiReferenceList {
|
|
||||||
protected SmaliBaseReferenceList(@NotNull StubT stub, @NotNull IStubElementType nodeType) {
|
|
||||||
super(stub, nodeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SmaliBaseReferenceList(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public SmaliClassType[] getReferencedTypes() {
|
|
||||||
StubT stub = getStub();
|
|
||||||
if (stub != null) {
|
|
||||||
return stub.getReferencedTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliClassTypeElement[] references = getReferenceElements();
|
|
||||||
|
|
||||||
SmaliClassType[] referenceTypes = new SmaliClassType[references.length];
|
|
||||||
|
|
||||||
for (int i=0; i<references.length; i++) {
|
|
||||||
referenceTypes[i] = references[i].getType();
|
|
||||||
}
|
|
||||||
return referenceTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull public String[] getReferenceNames() {
|
|
||||||
SmaliBaseReferenceListStub stub = getStub();
|
|
||||||
|
|
||||||
if (stub != null) {
|
|
||||||
String[] smaliNames = stub.getSmaliTypeNames();
|
|
||||||
String[] referenceNames = new String[smaliNames.length];
|
|
||||||
|
|
||||||
for (int i=0; i<smaliNames.length; i++) {
|
|
||||||
referenceNames[i] = NameUtils.resolveSmaliToJavaType(this, smaliNames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return referenceNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliClassTypeElement[] references = getReferenceElements();
|
|
||||||
|
|
||||||
String[] referenceNames = new String[references.length];
|
|
||||||
|
|
||||||
for (int i=0; i<references.length; i++) {
|
|
||||||
referenceNames[i] = references[i].getCanonicalText();
|
|
||||||
}
|
|
||||||
return referenceNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull public String[] getSmaliNames() {
|
|
||||||
SmaliBaseReferenceListStub stub = getStub();
|
|
||||||
|
|
||||||
if (stub != null) {
|
|
||||||
return stub.getSmaliTypeNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
SmaliClassTypeElement[] references = getReferenceElements();
|
|
||||||
|
|
||||||
String[] smaliNames = new String[references.length];
|
|
||||||
|
|
||||||
for (int i=0; i<references.length; i++) {
|
|
||||||
smaliNames[i] = references[i].getSmaliName();
|
|
||||||
}
|
|
||||||
return smaliNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean isWritable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public abstract SmaliClassTypeElement[] getReferenceElements();
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.smalidea.psi.impl;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jf.smalidea.psi.SmaliCompositeElementFactory;
|
|
||||||
import org.jf.smalidea.psi.SmaliElementTypes;
|
|
||||||
|
|
||||||
public class SmaliCatchAllStatement extends SmaliCatchStatement {
|
|
||||||
public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() {
|
|
||||||
@Override public SmaliCompositeElement createElement() {
|
|
||||||
return new SmaliCatchAllStatement();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public SmaliCatchAllStatement() {
|
|
||||||
super(SmaliElementTypes.CATCH_ALL_STATEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public SmaliClassTypeElement getExceptionType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user