diff --git a/NOTICE b/NOTICE index 7c80c51c..7f27c9f8 100644 --- a/NOTICE +++ b/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 -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: ******************************************************************************* @@ -77,26 +77,6 @@ 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. -******************************************************************************* - - -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 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/settings.gradle b/settings.gradle index f7a6cf75..6c4f08cf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1 @@ -include 'util', 'dexlib2', 'baksmali', 'smali', 'dexlib2:accessorTestGenerator' - -if (System.getProperty("user.dir").startsWith(file("smalidea").absolutePath)) { - include 'smalidea' -} \ No newline at end of file +include 'util', 'dexlib2', 'baksmali', 'smali', 'dexlib2:accessorTestGenerator' \ No newline at end of file diff --git a/smalidea/.gitignore b/smalidea/.gitignore deleted file mode 100644 index f8be3996..00000000 --- a/smalidea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build -test-config -test-system diff --git a/smalidea/build.gradle b/smalidea/build.gradle deleted file mode 100644 index 57209762..00000000 --- a/smalidea/build.gradle +++ /dev/null @@ -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(""" - - - - - - """)) - } - } - } - } - } - } - - 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' -})) \ No newline at end of file diff --git a/smalidea/src/main/antlr/smalideaParser.g b/smalidea/src/main/antlr/smalideaParser.g deleted file mode 100644 index f0eaf0e1..00000000 --- a/smalidea/src/main/antlr/smalideaParser.g +++ /dev/null @@ -1,1364 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - -parser grammar smalideaParser; - -options { - tokenVocab=smaliParser; -} - -@header { -package org.jf.smalidea; - -import com.intellij.lang.PsiBuilder; -import com.intellij.lang.PsiBuilder.Marker; -import com.intellij.psi.tree.IElementType; -import org.jf.smalidea.psi.SmaliElementTypes; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -} - - -@members { - private PsiBuilder psiBuilder; - - public void setPsiBuilder(PsiBuilder psiBuilder) { - this.psiBuilder = psiBuilder; - } - - public Marker mark() { - return psiBuilder.mark(); - } - - protected void syncToFollows(boolean acceptEof) { - BitSet follow = computeErrorRecoverySet(); - int mark = input.mark(); - Marker marker = null; - try { - int token = input.LA(1); - while (!follow.member(token)) { - if (token == Token.EOF) { - if (acceptEof) { - break; - } - input.rewind(mark); - mark = -1; - marker = null; - return; - } - if (marker == null) { - marker = mark(); - } - input.consume(); - token = input.LA(1); - } - } finally { - if (mark != -1) { - input.release(mark); - } - if (marker != null) { - marker.error("Unexpected tokens"); - } - } - } - - @Override - public void recover(IntStream input, RecognitionException re) { - BitSet followSet = computeErrorRecoverySet(); - beginResync(); - consumeUntil(input, followSet); - endResync(); - } - - @Override - protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) - throws RecognitionException - { - RecognitionException e = null; - // if next token is what we are looking for then "delete" this token - if ( mismatchIsUnwantedToken(input, ttype) ) { - e = new UnwantedTokenException(ttype, input); - beginResync(); - Marker mark = mark(); - input.consume(); // simply delete extra token - mark.error(getErrorMessage(e, tokenNames)); - endResync(); - reportError(null, e, true); // report after consuming so AW sees the token in the exception - // we want to return the token we're actually matching - Object matchedSymbol = getCurrentInputSymbol(input); - input.consume(); // move past ttype token as if all were ok - return matchedSymbol; - } - // can't recover with single token deletion, try insertion - if ( mismatchIsMissingToken(input, follow) ) { - Object inserted = getMissingSymbol(input, e, ttype, follow); - Marker mark = mark(); - e = new MissingTokenException(ttype, input, inserted); - mark.error(getErrorMessage(e, tokenNames)); - reportError(null, e, true); // report after inserting so AW sees the token in the exception - return inserted; - } - - // even that didn't work; must throw the exception - e = new MismatchedTokenException(ttype, input); - throw e; - } - - @Override - public void reportError(RecognitionException e) { - reportError(mark(), e, false); - } - - public void reportError(@Nullable Marker marker, RecognitionException e, boolean alreadyReported) { - // if we've already reported an error and have not matched a token - // yet successfully, don't report any errors. - if ( state.errorRecovery ) { - if (marker != null) { - marker.drop(); - } - return; - } - state.syntaxErrors++; // don't count spurious - state.errorRecovery = true; - - if (marker != null) { - if (!alreadyReported) { - displayRecognitionError(marker, this.getTokenNames(), e); - } else { - marker.drop(); - } - } - } - - public void finishToken(Marker marker, IElementType elementType) { - if (state.errorRecovery) { - marker.drop(); - } else { - marker.done(elementType); - } - } - - @Override - public void displayRecognitionError(String[] tokenNames, RecognitionException e) { - displayRecognitionError(mark(), tokenNames, e); - } - - public void displayRecognitionError(@Nonnull Marker marker, String[] tokenNames, RecognitionException e) { - marker.error(getErrorMessage(e, tokenNames)); - } -} - -sync[boolean toEof] - @init { syncToFollows($toEof); } - : /*epsilon*/; - -smali_file - @init { - mark().done(SmaliElementTypes.EXTENDS_LIST); - mark().done(SmaliElementTypes.IMPLEMENTS_LIST); - } - : - ( - ( class_spec - | super_spec - | implements_spec - | source_spec - | method - | field - | annotation - ) - sync[true] - )+ - EOF; - -class_spec - @init { Marker marker = mark(); } - : CLASS_DIRECTIVE class_access_list class_descriptor - { marker.done(SmaliElementTypes.CLASS_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -super_spec - @init { Marker marker = mark(); } - : SUPER_DIRECTIVE class_descriptor - { marker.done(SmaliElementTypes.SUPER_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -implements_spec - @init { Marker marker = mark(); } - : IMPLEMENTS_DIRECTIVE class_descriptor - { marker.done(SmaliElementTypes.IMPLEMENTS_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -source_spec - @init { Marker marker = mark(); } - : SOURCE_DIRECTIVE string_literal - { marker.done(SmaliElementTypes.SOURCE_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -// class_access_list should be separate from access_list, because -// it exists in a slightly different context, and can consume -// ACCESS_SPECs greedily, without having to look ahead. -class_access_list - @init { Marker marker = mark(); } - : ACCESS_SPEC* - { marker.done(SmaliElementTypes.MODIFIER_LIST); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -access_list - @init { Marker marker = mark(); } - : ACCESS_SPEC* - { marker.done(SmaliElementTypes.MODIFIER_LIST); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -/*When there are annotations immediately after a field definition, we don't know whether they are field annotations -or class annotations until we determine if there is an .end field directive. In either case, we still "consume" and parse -the annotations. If it turns out that they are field annotations, we include them in the I_FIELD AST. Otherwise, we -add them to the $smali_file::classAnnotations list*/ -field - @init { - Marker marker = mark(); - Marker annotationsMarker = null; - boolean gotEndField = false; - } - : FIELD_DIRECTIVE - access_list - member_name colon nonvoid_type_descriptor - field_initializer? - ( - (ANNOTATION_DIRECTIVE)=> ( - { annotationsMarker = mark(); } - ((ANNOTATION_DIRECTIVE)=> annotation)+ - ) - )? - ( end_field_directive { gotEndField = true; } )? - { - if (annotationsMarker != null) { - if (gotEndField) { - annotationsMarker.drop(); - marker.done(SmaliElementTypes.FIELD); - } else { - marker.doneBefore(SmaliElementTypes.FIELD, annotationsMarker); - annotationsMarker.drop(); - } - } else { - marker.done(SmaliElementTypes.FIELD); - } - }; - catch [RecognitionException re] { - if (annotationsMarker != null) { - annotationsMarker.drop(); - } - recover(input, re); - reportError(marker, re, false); - } - -end_field_directive - : END_FIELD_DIRECTIVE; - -field_initializer - @init { Marker marker = mark(); } - : EQUAL literal - { marker.done(SmaliElementTypes.FIELD_INITIALIZER); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -method - @init { - Marker marker = mark(); - mark().done(SmaliElementTypes.THROWS_LIST); - } - : METHOD_DIRECTIVE access_list member_name method_prototype statements_and_directives - end_method_directive - { marker.done(SmaliElementTypes.METHOD); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -end_method_directive - : END_METHOD_DIRECTIVE; -catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -statements_and_directives - : ( - ( ordered_method_item - | registers_directive - | catch_directive - | catchall_directive - | parameter_directive - | annotation - ) - sync[false] - )*; - -/* Method items whose order/location is important */ -ordered_method_item - : label - | instruction - | debug_directive; - -registers_directive - @init { Marker marker = mark(); } - : ( - REGISTERS_DIRECTIVE integral_literal - | LOCALS_DIRECTIVE integral_literal - ) - { marker.done(SmaliElementTypes.REGISTERS_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -param_list_or_id - : PARAM_LIST_OR_ID_PRIMITIVE_TYPE+; - -/*identifiers are much more general than most languages. Any of the below can either be -the indicated type OR an identifier, depending on the context*/ -simple_name - : SIMPLE_NAME - | ACCESS_SPEC - | VERIFICATION_ERROR_TYPE - | POSITIVE_INTEGER_LITERAL - | NEGATIVE_INTEGER_LITERAL - | FLOAT_LITERAL_OR_ID - | DOUBLE_LITERAL_OR_ID - | BOOL_LITERAL - | NULL_LITERAL - | register - | param_list_or_id - | PRIMITIVE_TYPE - | VOID_TYPE - | ANNOTATION_VISIBILITY - | INSTRUCTION_FORMAT10t - | INSTRUCTION_FORMAT10x - | INSTRUCTION_FORMAT10x_ODEX - | INSTRUCTION_FORMAT11x - | INSTRUCTION_FORMAT12x_OR_ID - | INSTRUCTION_FORMAT21c_FIELD - | INSTRUCTION_FORMAT21c_FIELD_ODEX - | INSTRUCTION_FORMAT21c_STRING - | INSTRUCTION_FORMAT21c_TYPE - | INSTRUCTION_FORMAT21t - | INSTRUCTION_FORMAT22c_FIELD - | INSTRUCTION_FORMAT22c_FIELD_ODEX - | INSTRUCTION_FORMAT22c_TYPE - | INSTRUCTION_FORMAT22cs_FIELD - | INSTRUCTION_FORMAT22s_OR_ID - | INSTRUCTION_FORMAT22t - | INSTRUCTION_FORMAT23x - | INSTRUCTION_FORMAT31i_OR_ID - | INSTRUCTION_FORMAT31t - | INSTRUCTION_FORMAT35c_METHOD - | INSTRUCTION_FORMAT35c_METHOD_ODEX - | INSTRUCTION_FORMAT35c_METHOD_OR_METHOD_HANDLE_TYPE - | INSTRUCTION_FORMAT35c_TYPE - | INSTRUCTION_FORMAT35mi_METHOD - | INSTRUCTION_FORMAT35ms_METHOD - | INSTRUCTION_FORMAT51l; - -member_name - @init { Marker marker = mark(); } - : member_name_inner - { marker.done(SmaliElementTypes.MEMBER_NAME); }; - -member_name_inner - : (simple_name - | MEMBER_NAME); - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -method_prototype - @init { Marker marker = mark(); } - : open_paren param_list close_paren type_descriptor - { marker.done(SmaliElementTypes.METHOD_PROTOTYPE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -open_paren - : OPEN_PAREN; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -close_paren - : CLOSE_PAREN; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -open_brace - : OPEN_BRACE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -close_brace - : CLOSE_BRACE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -comma - : COMMA; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -colon - : COLON; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -dotdot - : DOTDOT; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -param_list_inner - : param+; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -param_list - @init { Marker marker = mark(); } - : param_list_inner? - { marker.done(SmaliElementTypes.METHOD_PARAM_LIST); }; - -param - @init { - Marker marker = mark(); - mark().done(SmaliElementTypes.MODIFIER_LIST); - } - : nonvoid_type_descriptor - { marker.done(SmaliElementTypes.METHOD_PARAMETER); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -method_prototype_reference - : open_paren param_list_reference close_paren type_descriptor; - -param_list_reference - @init { - Marker marker = mark(); - } - : nonvoid_type_descriptor* - { marker.done(SmaliElementTypes.METHOD_REFERENCE_PARAM_LIST); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -primitive_type - @init { Marker marker = mark(); } - : (PRIMITIVE_TYPE | PARAM_LIST_OR_ID_PRIMITIVE_TYPE) - { finishToken(marker, SmaliElementTypes.PRIMITIVE_TYPE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -class_descriptor - @init { Marker marker = mark(); } - : CLASS_DESCRIPTOR - { finishToken(marker, SmaliElementTypes.CLASS_TYPE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -array_descriptor - @init { Marker marker = mark(); } - : ARRAY_TYPE_PREFIX (primitive_type | class_descriptor) - { finishToken(marker, SmaliElementTypes.ARRAY_TYPE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -void_type - @init { Marker marker = mark(); } - : VOID_TYPE - { finishToken(marker, SmaliElementTypes.VOID_TYPE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -type_descriptor - : void_type - | primitive_type - | class_descriptor - | array_descriptor; - catch [RecognitionException re] { - Marker marker = mark(); - recover(input, re); - reportError(marker, re, false); - } - -nonvoid_type_descriptor - : primitive_type - | class_descriptor - | array_descriptor; - catch [RecognitionException re] { - Marker marker = mark(); - recover(input, re); - reportError(marker, re, false); - } - -reference_type_descriptor - : class_descriptor - | array_descriptor; - catch [RecognitionException re] { - Marker marker = mark(); - recover(input, re); - reportError(marker, re, false); - } - -null_literal - @init { Marker marker = mark(); } - : NULL_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -bool_literal - @init { Marker marker = mark(); } - : BOOL_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -byte_literal - @init { Marker marker = mark(); } - : BYTE_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -char_literal - @init { Marker marker = mark(); } - : CHAR_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -short_literal - @init { Marker marker = mark(); } - : SHORT_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -integer_literal - @init { Marker marker = mark(); } - : ( POSITIVE_INTEGER_LITERAL - | NEGATIVE_INTEGER_LITERAL) - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -long_literal - @init { Marker marker = mark(); } - : LONG_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -float_literal - @init { Marker marker = mark(); } - : ( FLOAT_LITERAL_OR_ID - | FLOAT_LITERAL ) - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -double_literal - @init { Marker marker = mark(); } - : ( DOUBLE_LITERAL_OR_ID - | DOUBLE_LITERAL) - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -string_literal - @init { Marker marker = mark(); } - : STRING_LITERAL - { finishToken(marker, SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -array_literal - @init { Marker marker = mark(); } - : open_brace (literal (comma literal)* | ) close_brace - { marker.done(SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -enum_literal - @init { Marker marker = mark(); } - : ENUM_DIRECTIVE fully_qualified_field - { marker.done(SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -type_field_method_literal - @init { Marker marker = mark(); } - : ( type_descriptor - | fully_qualified_field - | fully_qualified_method) - { marker.done(SmaliElementTypes.LITERAL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -subannotation - @init { - Marker marker = mark(); - Marker paramListMarker = null; - } - : SUBANNOTATION_DIRECTIVE class_descriptor - { paramListMarker = mark(); } - annotation_element* - { paramListMarker.done(SmaliElementTypes.ANNOTATION_PARAMETER_LIST); } - end_subannotation_directive - { marker.done(SmaliElementTypes.ANNOTATION); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -end_subannotation_directive - : END_SUBANNOTATION_DIRECTIVE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -literal - : long_literal - | integer_literal - | short_literal - | byte_literal - | float_literal - | double_literal - | char_literal - | string_literal - | bool_literal - | null_literal - | array_literal - | subannotation - | type_field_method_literal - | enum_literal; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -string_or_null_literal - : string_literal - | null_literal; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -integral_literal - : long_literal - | integer_literal - | short_literal - | char_literal - | byte_literal; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -fixed_32bit_literal - : long_literal - | integer_literal - | short_literal - | byte_literal - | float_literal - | char_literal - | bool_literal; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -fixed_literal - : integer_literal - | long_literal - | short_literal - | byte_literal - | float_literal - | double_literal - | char_literal - | bool_literal; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -annotation_element - @init { - Marker marker = mark(); - Marker nameMarker = null; - } - : { nameMarker = mark(); } simple_name { nameMarker.done(SmaliElementTypes.ANNOTATION_ELEMENT_NAME); } - equal literal - { marker.done(SmaliElementTypes.ANNOTATION_ELEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -equal - : EQUAL; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -annotation - @init { - Marker marker = mark(); - Marker paramListMarker = null; - } - : ANNOTATION_DIRECTIVE annotation_visibility class_descriptor - { paramListMarker = mark(); } - annotation_element* - { paramListMarker.done(SmaliElementTypes.ANNOTATION_PARAMETER_LIST); } - end_annotation_directive - { marker.done(SmaliElementTypes.ANNOTATION); }; - -annotation_visibility - : ANNOTATION_VISIBILITY; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -end_annotation_directive - : END_ANNOTATION_DIRECTIVE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -arrow - : ARROW; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -fully_qualified_method - @init { Marker marker = mark(); } - : reference_type_descriptor arrow member_name method_prototype_reference - { marker.done(SmaliElementTypes.METHOD_REFERENCE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -fully_qualified_field - @init { Marker marker = mark(); } - : reference_type_descriptor arrow member_name colon nonvoid_type_descriptor - { marker.done(SmaliElementTypes.FIELD_REFERENCE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -label - @init { Marker marker = mark(); } - : colon simple_name - { marker.done(SmaliElementTypes.LABEL); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -label_ref - @init { Marker marker = mark(); } - : colon simple_name - { marker.done(SmaliElementTypes.LABEL_REFERENCE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -register_list - : open_brace (register (comma register)*)? close_brace; - -register_range - : open_brace (register (dotdot register)?)? close_brace; - -verification_error_reference - : class_descriptor | fully_qualified_field | fully_qualified_method; - -catch_directive - @init { Marker marker = mark(); } - : CATCH_DIRECTIVE nonvoid_type_descriptor open_brace label_ref dotdot label_ref close_brace label_ref - { marker.done(SmaliElementTypes.CATCH_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -catchall_directive - @init { Marker marker = mark(); } - : CATCHALL_DIRECTIVE open_brace label_ref dotdot label_ref close_brace label_ref - { marker.done(SmaliElementTypes.CATCH_ALL_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -/*When there are annotations immediately after a parameter definition, we don't know whether they are parameter annotations -or method annotations until we determine if there is an .end parameter directive. In either case, we still "consume" and parse -the annotations. If it turns out that they are parameter annotations, we include them in the I_PARAMETER AST. Otherwise, we -add them to the $statements_and_directives::methodAnnotations list*/ -parameter_directive - @init { - Marker marker = mark(); - Marker annotationsMarker = null; - boolean gotEndParam = false; - } - : PARAMETER_DIRECTIVE register - (comma local_name)? - { annotationsMarker = mark(); } parameter_annotations - ( end_parameter_directive { gotEndParam = true; } )? - { - if (gotEndParam) { - annotationsMarker.drop(); - marker.done(SmaliElementTypes.PARAMETER_STATEMENT); - } else { - marker.doneBefore(SmaliElementTypes.PARAMETER_STATEMENT, annotationsMarker); - annotationsMarker.drop(); - } - }; - catch [RecognitionException re] { - if (annotationsMarker != null) { - annotationsMarker.drop(); - } - recover(input, re); - reportError(marker, re, false); - } - -parameter_annotations - : ((ANNOTATION_DIRECTIVE)=> annotation)*; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -end_parameter_directive - : END_PARAMETER_DIRECTIVE; - -local_name - @init { - Marker localNameMarker = mark(); - Marker stringMarker = mark(); - } - : STRING_LITERAL - { - finishToken(stringMarker, SmaliElementTypes.LITERAL); - finishToken(localNameMarker, SmaliElementTypes.LOCAL_NAME); - }; - catch [RecognitionException re] { - stringMarker.drop(); - recover(input, re); - reportError(localNameMarker, re, false); - } - -register - @init { Marker marker = mark(); } - : REGISTER - { finishToken(marker, SmaliElementTypes.REGISTER_REFERENCE); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -debug_directive - : line_directive - | local_directive - | end_local_directive - | restart_local_directive - | prologue_directive - | epilogue_directive - | source_directive; - -line_directive - @init { Marker marker = mark(); } - : LINE_DIRECTIVE integral_literal - { marker.done(SmaliElementTypes.LINE_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -local_directive - @init { Marker marker = mark(); } - : LOCAL_DIRECTIVE register (comma string_or_null_literal colon type_descriptor - (comma string_literal)? )? - { marker.done(SmaliElementTypes.LOCAL_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -end_local_directive - @init { Marker marker = mark(); } - : END_LOCAL_DIRECTIVE register - { marker.done(SmaliElementTypes.END_LOCAL_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -restart_local_directive - @init { Marker marker = mark(); } - : RESTART_LOCAL_DIRECTIVE register - { marker.done(SmaliElementTypes.RESTART_LOCAL_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -prologue_directive - @init { Marker marker = mark(); } - : PROLOGUE_DIRECTIVE - { marker.done(SmaliElementTypes.PROLOGUE_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -epilogue_directive - @init { Marker marker = mark(); } - : EPILOGUE_DIRECTIVE - { marker.done(SmaliElementTypes.EPILOGUE_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -source_directive - @init { Marker marker = mark(); } - : SOURCE_DIRECTIVE string_literal? - { marker.done(SmaliElementTypes.SOURCE_DEBUG_STATEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -instruction_format12x - : INSTRUCTION_FORMAT12x - | INSTRUCTION_FORMAT12x_OR_ID; - -instruction_format22s - : INSTRUCTION_FORMAT22s - | INSTRUCTION_FORMAT22s_OR_ID; - -instruction_format31i - : INSTRUCTION_FORMAT31i - | INSTRUCTION_FORMAT31i_OR_ID; - -instruction - @init { Marker marker = mark(); } - : ( insn_format10t - | insn_format10x - | insn_format10x_odex - | insn_format11n - | insn_format11x - | insn_format12x - | insn_format20bc - | insn_format20t - | insn_format21c_field - | insn_format21c_field_odex - | insn_format21c_string - | insn_format21c_type - | insn_format21ih - | insn_format21lh - | insn_format21s - | insn_format21t - | insn_format22b - | insn_format22c_field - | insn_format22c_field_odex - | insn_format22c_type - | insn_format22cs_field - | insn_format22s - | insn_format22t - | insn_format22x - | insn_format23x - | insn_format30t - | insn_format31c - | insn_format31i - | insn_format31t - | insn_format32x - | insn_format35c_method - | insn_format35c_type - | insn_format35c_method_odex - | insn_format35mi_method - | insn_format35ms_method - | insn_format3rc_method - | insn_format3rc_method_odex - | insn_format3rc_type - | insn_format3rmi_method - | insn_format3rms_method - | insn_format51l - | insn_array_data_directive - | insn_packed_switch_directive - | insn_sparse_switch_directive ) - { marker.done(SmaliElementTypes.INSTRUCTION); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -insn_format10t - : //e.g. goto endloop: - //e.g. goto +3 - INSTRUCTION_FORMAT10t label_ref; - -insn_format10x - : //e.g. return-void - INSTRUCTION_FORMAT10x; - -insn_format10x_odex - : //e.g. return-void-barrier - INSTRUCTION_FORMAT10x_ODEX; - -insn_format11n - : //e.g. const/4 v0, 5 - INSTRUCTION_FORMAT11n register comma integral_literal; - -insn_format11x - : //e.g. move-result-object v1 - INSTRUCTION_FORMAT11x register; - -insn_format12x - : //e.g. move v1 v2 - instruction_format12x register comma register; - -insn_format20bc - : //e.g. throw-verification-error generic-error, Lsome/class; - INSTRUCTION_FORMAT20bc VERIFICATION_ERROR_TYPE comma verification_error_reference; - -insn_format20t - : //e.g. goto/16 endloop: - INSTRUCTION_FORMAT20t label_ref; - -insn_format21c_field - : //e.g. sget-object v0, java/lang/System/out LJava/io/PrintStream; - INSTRUCTION_FORMAT21c_FIELD register comma fully_qualified_field; - -insn_format21c_field_odex - : //e.g. sget-object-volatile v0, java/lang/System/out LJava/io/PrintStream; - INSTRUCTION_FORMAT21c_FIELD_ODEX register comma fully_qualified_field; - -insn_format21c_string - : //e.g. const-string v1, "Hello World!" - INSTRUCTION_FORMAT21c_STRING register comma string_literal; - -insn_format21c_type - : //e.g. const-class v2, Lorg/jf/HelloWorld2/HelloWorld2; - INSTRUCTION_FORMAT21c_TYPE register comma nonvoid_type_descriptor; - -insn_format21ih - : //e.g. const/high16 v1, 1234 - INSTRUCTION_FORMAT21ih register comma fixed_32bit_literal; - -insn_format21lh - : //e.g. const-wide/high16 v1, 1234 - INSTRUCTION_FORMAT21lh register comma fixed_32bit_literal; - -insn_format21s - : //e.g. const/16 v1, 1234 - INSTRUCTION_FORMAT21s register comma integral_literal; - -insn_format21t - : //e.g. if-eqz v0, endloop: - INSTRUCTION_FORMAT21t register comma label_ref; - -insn_format22b - : //e.g. add-int v0, v1, 123 - INSTRUCTION_FORMAT22b register comma register comma integral_literal; - -insn_format22c_field - : //e.g. iput-object v1, v0 org/jf/HelloWorld2/HelloWorld2.helloWorld Ljava/lang/String; - INSTRUCTION_FORMAT22c_FIELD register comma register comma fully_qualified_field; - -insn_format22c_field_odex - : //e.g. iput-object-volatile v1, v0 org/jf/HelloWorld2/HelloWorld2.helloWorld Ljava/lang/String; - INSTRUCTION_FORMAT22c_FIELD_ODEX register comma register comma fully_qualified_field; - -insn_format22c_type - : //e.g. instance-of v0, v1, Ljava/lang/String; - INSTRUCTION_FORMAT22c_TYPE register comma register comma nonvoid_type_descriptor; - -insn_format22cs_field - : //e.g. iget-quick v0, v1, field@0xc - INSTRUCTION_FORMAT22cs_FIELD register comma register comma FIELD_OFFSET; - -insn_format22s - : //e.g. add-int/lit16 v0, v1, 12345 - instruction_format22s register comma register comma integral_literal; - -insn_format22t - : //e.g. if-eq v0, v1, endloop: - INSTRUCTION_FORMAT22t register comma register comma label_ref; - -insn_format22x - : //e.g. move/from16 v1, v1234 - INSTRUCTION_FORMAT22x register comma register; - -insn_format23x - : //e.g. add-int v1, v2, v3 - INSTRUCTION_FORMAT23x register comma register comma register; - -insn_format30t - : //e.g. goto/32 endloop: - INSTRUCTION_FORMAT30t label_ref; - -insn_format31c - : //e.g. const-string/jumbo v1 "Hello World!" - INSTRUCTION_FORMAT31c register comma string_literal; - -insn_format31i - : //e.g. const v0, 123456 - instruction_format31i register comma fixed_32bit_literal; - -insn_format31t - : //e.g. fill-array-data v0, ArrayData: - INSTRUCTION_FORMAT31t register comma label_ref; - -insn_format32x - : //e.g. move/16 v4567, v1234 - INSTRUCTION_FORMAT32x register comma register; - -insn_format35c_method - : //e.g. invoke-virtual {v0,v1} java/io/PrintStream/print(Ljava/lang/Stream;)V - (INSTRUCTION_FORMAT35c_METHOD | INSTRUCTION_FORMAT35c_METHOD_OR_METHOD_HANDLE_TYPE) register_list comma fully_qualified_method; - -insn_format35c_type - : //e.g. filled-new-array {v0,v1}, I - INSTRUCTION_FORMAT35c_TYPE register_list comma nonvoid_type_descriptor; - -insn_format35c_method_odex - : //e.g. invoke-direct {p0}, Ljava/lang/Object;->()V - INSTRUCTION_FORMAT35c_METHOD_ODEX register_list comma fully_qualified_method; - -insn_format35mi_method - : //e.g. execute-inline {v0, v1}, inline@0x4 - INSTRUCTION_FORMAT35mi_METHOD register_list comma INLINE_INDEX; - -insn_format35ms_method - : //e.g. invoke-virtual-quick {v0, v1}, vtable@0x4 - INSTRUCTION_FORMAT35ms_METHOD register_list comma VTABLE_INDEX; - -insn_format3rc_method - : //e.g. invoke-virtual/range {v25..v26}, java/lang/StringBuilder/append(Ljava/lang/String;)Ljava/lang/StringBuilder; - INSTRUCTION_FORMAT3rc_METHOD register_range comma fully_qualified_method; - -insn_format3rc_method_odex - : //e.g. invoke-object-init/range {p0}, Ljava/lang/Object;->()V - INSTRUCTION_FORMAT3rc_METHOD_ODEX register_list comma fully_qualified_method; - -insn_format3rc_type - : //e.g. filled-new-array/range {v0..v6}, I - INSTRUCTION_FORMAT3rc_TYPE register_range comma nonvoid_type_descriptor; - -insn_format3rmi_method - : //e.g. execute-inline/range {v0 .. v10}, inline@0x14 - INSTRUCTION_FORMAT3rmi_METHOD register_range comma INLINE_INDEX; - -insn_format3rms_method - : //e.g. invoke-virtual-quick/range {v0 .. v10}, vtable@0x14 - INSTRUCTION_FORMAT3rms_METHOD register_range comma VTABLE_INDEX; - -insn_format51l - : //e.g. const-wide v0, 5000000000L - INSTRUCTION_FORMAT51l register comma fixed_literal; - -insn_array_data_directive - : ARRAY_DATA_DIRECTIVE - integer_literal - array_data_element* end_array_data_directive; - -end_array_data_directive - : END_ARRAY_DATA_DIRECTIVE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -array_data_element - @init { Marker marker = mark(); } - : fixed_literal - { marker.done(SmaliElementTypes.ARRAY_DATA_ELEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -insn_packed_switch_directive - : PACKED_SWITCH_DIRECTIVE - fixed_32bit_literal - packed_switch_element* - end_packed_switch_directive; - -end_packed_switch_directive - : END_PACKED_SWITCH_DIRECTIVE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -packed_switch_element - @init { Marker marker = mark(); } - : label_ref - { marker.done(SmaliElementTypes.PACKED_SWITCH_ELEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } - -insn_sparse_switch_directive - : SPARSE_SWITCH_DIRECTIVE - sparse_switch_element* - end_sparse_switch_directive; - -end_sparse_switch_directive - : END_SPARSE_SWITCH_DIRECTIVE; - catch [RecognitionException re] { - Marker errorMarker = mark(); - recover(input, re); - reportError(errorMarker, re, false); - } - -sparse_switch_element - @init { Marker marker = mark(); } - : fixed_32bit_literal arrow label_ref - { marker.done(SmaliElementTypes.SPARSE_SWITCH_ELEMENT); }; - catch [RecognitionException re] { - recover(input, re); - reportError(marker, re, false); - } diff --git a/smalidea/src/main/java/org/jf/smalidea/PsiBuilderTokenStream.java b/smalidea/src/main/java/org/jf/smalidea/PsiBuilderTokenStream.java deleted file mode 100644 index 00004001..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/PsiBuilderTokenStream.java +++ /dev/null @@ -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 markers = new ArrayList(); - - 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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliASTFactory.java b/smalidea/src/main/java/org/jf/smalidea/SmaliASTFactory.java deleted file mode 100644 index 4e0208c2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliASTFactory.java +++ /dev/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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliColorsPage.java b/smalidea/src/main/java/org/jf/smalidea/SmaliColorsPage.java deleted file mode 100644 index b0ed5c04..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliColorsPage.java +++ /dev/null @@ -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 keys = SmaliHighlightingColors.getAllKeys(); - - ATTRS = new AttributesDescriptor[keys.size()]; - for (int i=0; i()V\n" + - " .registers 1\n" + - " invoke-direct {p0}, Ljava/lang/Object;->()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 getAdditionalHighlightingTagToDescriptorMap() { - return null; - } - - @NotNull @Override public ColorDescriptor[] getColorDescriptors() { - return ColorDescriptor.EMPTY_ARRAY; - } - - @NotNull @Override public String getDisplayName() { - return "smali"; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java b/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java deleted file mode 100644 index e840bb8d..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java b/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java deleted file mode 100644 index b5834c18..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliHighlighter.java b/smalidea/src/main/java/org/jf/smalidea/SmaliHighlighter.java deleted file mode 100644 index 71e206a0..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliHighlighter.java +++ /dev/null @@ -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 -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliHighlightingColors.java b/smalidea/src/main/java/org/jf/smalidea/SmaliHighlightingColors.java deleted file mode 100644 index eba5fd33..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliHighlightingColors.java +++ /dev/null @@ -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 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 getAllKeys() { - return Collections.unmodifiableList(allKeys); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java b/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java deleted file mode 100644 index 449e71b5..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java +++ /dev/null @@ -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"); -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java b/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java deleted file mode 100644 index f437ec27..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliLexer.java b/smalidea/src/main/java/org/jf/smalidea/SmaliLexer.java deleted file mode 100644 index 515749fa..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliLexer.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliLexicalElementType.java b/smalidea/src/main/java/org/jf/smalidea/SmaliLexicalElementType.java deleted file mode 100644 index 5103dd9e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliLexicalElementType.java +++ /dev/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}; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliParser.java b/smalidea/src/main/java/org/jf/smalidea/SmaliParser.java deleted file mode 100644 index ed0fb19a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliParser.java +++ /dev/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; - - -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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliParserDefinition.java b/smalidea/src/main/java/org/jf/smalidea/SmaliParserDefinition.java deleted file mode 100644 index 77f1623a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliParserDefinition.java +++ /dev/null @@ -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()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliTokens.java b/smalidea/src/main/java/org/jf/smalidea/SmaliTokens.java deleted file mode 100644 index 248c5bdb..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/SmaliTokens.java +++ /dev/null @@ -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 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> 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 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 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 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 registerMap = Maps.newHashMap(); - StringBuilder variablesText = new StringBuilder(); - for (int i=0; i= 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() { - @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 localVariableConstructor = LocalVariableImpl.class.getDeclaredConstructor( - VirtualMachine.class, Method.class, Integer.TYPE, Location.class, Location.class, String.class, - String.class, String.class); - localVariableConstructor.setAccessible(true); - - Constructor 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() { - @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() { - @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; - } - }); - } -} - diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliExpressionEvaluator.java b/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliExpressionEvaluator.java deleted file mode 100644 index 89bba297..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliExpressionEvaluator.java +++ /dev/null @@ -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 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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManager.java b/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManager.java deleted file mode 100644 index 9c0abbe6..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManager.java +++ /dev/null @@ -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 classes = ApplicationManager.getApplication().runReadAction( - new Computable>() { - @Override public Collection 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 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() { - @Override public String compute() { - SmaliClass smaliClass = ((SmaliFile)position.getElementAt().getContainingFile()).getPsiClass(); - if (smaliClass == null) { - return ""; - } - return smaliClass.getQualifiedName(); - } - }); - } - - @Override @NotNull - public List locationsOfLine(@NotNull final ReferenceType type, - @NotNull final SourcePosition position) throws NoDataException { - PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override public PsiFile compute() { - return position.getElementAt().getContainingFile(); - } - }); - - if (!(containingFile instanceof SmaliFile)) { - throw NoDataException.INSTANCE; - } - - final ArrayList locations = new ArrayList(1); - - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - public void run() { - - - String typeName = type.name(); - Collection 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 isSmaliFile = new Computable() { - @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); - } -} \ No newline at end of file diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManagerFactory.java b/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManagerFactory.java deleted file mode 100644 index d78b57c8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliPositionManagerFactory.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliSteppingCommandProvider.java b/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliSteppingCommandProvider.java deleted file mode 100644 index 8c756810..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/SmaliSteppingCommandProvider.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyArrayReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyArrayReference.java deleted file mode 100644 index ad55a9f0..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyArrayReference.java +++ /dev/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 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 getValues() { - return getValue().getValues(); - } - - public List 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 values, int srcIndex, int length) throws InvalidTypeException, ClassNotLoadedException { - getValue().setValues(index, values, srcIndex, length); - } - - public void setValues(List values) throws InvalidTypeException, ClassNotLoadedException { - getValue().setValues(values); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyBooleanValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyBooleanValue.java deleted file mode 100644 index e42da259..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyBooleanValue.java +++ /dev/null @@ -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 implements BooleanValue { - public LazyBooleanValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public boolean value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyByteValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyByteValue.java deleted file mode 100644 index bc0e6a38..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyByteValue.java +++ /dev/null @@ -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 implements ByteValue { - public LazyByteValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public byte value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyCharValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyCharValue.java deleted file mode 100644 index 0c536dd9..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyCharValue.java +++ /dev/null @@ -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 implements CharValue { - public LazyCharValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public char value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassLoaderReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassLoaderReference.java deleted file mode 100644 index dc41bbb5..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassLoaderReference.java +++ /dev/null @@ -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 - implements ClassLoaderReference { - public LazyClassLoaderReference(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - public List definedClasses() { - return getValue().definedClasses(); - } - - public List visibleClasses() { - return getValue().visibleClasses(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassObjectReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassObjectReference.java deleted file mode 100644 index 62ac4203..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyClassObjectReference.java +++ /dev/null @@ -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 - implements ClassObjectReference { - public LazyClassObjectReference(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - public ReferenceType reflectedType() { - return getValue().reflectedType(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyComparablePrimitiveValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyComparablePrimitiveValue.java deleted file mode 100644 index e4a0b332..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyComparablePrimitiveValue.java +++ /dev/null @@ -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> extends LazyPrimitiveValue - implements Comparable { - public LazyComparablePrimitiveValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - public int compareTo(T o) { - return getValue().compareTo(o); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyDoubleValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyDoubleValue.java deleted file mode 100644 index ae9e17a8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyDoubleValue.java +++ /dev/null @@ -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 implements DoubleValue { - public LazyDoubleValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public double value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyFloatValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyFloatValue.java deleted file mode 100644 index 54041cd6..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyFloatValue.java +++ /dev/null @@ -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 implements FloatValue { - public LazyFloatValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public float value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyIntegerValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyIntegerValue.java deleted file mode 100644 index 87b13caf..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyIntegerValue.java +++ /dev/null @@ -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 implements IntegerValue { - public LazyIntegerValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public int value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyLongValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyLongValue.java deleted file mode 100644 index e1c1aafc..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyLongValue.java +++ /dev/null @@ -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 implements LongValue { - public LazyLongValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public long value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyObjectReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyObjectReference.java deleted file mode 100644 index 9f50bf3f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyObjectReference.java +++ /dev/null @@ -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 extends LazyValue 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 getValues(List 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 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 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 referringObjects(long maxReferrers) { - return getValue().referringObjects(maxReferrers); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyPrimitiveValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyPrimitiveValue.java deleted file mode 100644 index 65d36357..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyPrimitiveValue.java +++ /dev/null @@ -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 extends LazyValue 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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyShortValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyShortValue.java deleted file mode 100644 index 10a5fa32..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyShortValue.java +++ /dev/null @@ -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 implements ShortValue { - public LazyShortValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } - - @Override public short value() { - return getValue().value(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyStringReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyStringReference.java deleted file mode 100644 index 2b52e2b7..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyStringReference.java +++ /dev/null @@ -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 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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadGroupReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadGroupReference.java deleted file mode 100644 index 05f05d63..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadGroupReference.java +++ /dev/null @@ -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 - 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 threadGroups() { - return getValue().threadGroups(); - } - - @Override public List threads() { - return getValue().threads(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadReference.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadReference.java deleted file mode 100644 index 61a13f88..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyThreadReference.java +++ /dev/null @@ -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 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 frames() throws IncompatibleThreadStateException { - return getValue().frames(); - } - - public List 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 ownedMonitors() throws IncompatibleThreadStateException { - return getValue().ownedMonitors(); - } - - public List 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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyValue.java deleted file mode 100644 index f17df6d7..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyValue.java +++ /dev/null @@ -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 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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyVoidValue.java b/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyVoidValue.java deleted file mode 100644 index a7f6bdc5..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/debugging/value/LazyVoidValue.java +++ /dev/null @@ -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 implements VoidValue { - public LazyVoidValue(SmaliMethod method, Project project, int registerNumber, String type) { - super(method, project, registerNumber, type); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaClassDef.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaClassDef.java deleted file mode 100644 index c954702a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaClassDef.java +++ /dev/null @@ -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 getInterfaces() { - List 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 getAnnotations() { - return ImmutableSet.of(); - } - - @Nonnull @Override public Iterable getStaticFields() { - return Iterables.transform( - Iterables.filter(Arrays.asList(psiClass.getFields()), new Predicate() { - @Override public boolean apply(PsiField psiField) { - PsiModifierList modifierList = psiField.getModifierList(); - if (modifierList == null) { - return false; - } - return modifierList.hasModifierProperty("static"); - } - }), - new Function() { - @Nullable @Override public Field apply(@Nullable PsiField psiField) { - return new SmalideaField(psiField); - } - }); - } - - @Nonnull @Override public Iterable getInstanceFields() { - return Iterables.transform( - Iterables.filter(Arrays.asList(psiClass.getFields()), new Predicate() { - @Override public boolean apply(PsiField psiField) { - PsiModifierList modifierList = psiField.getModifierList(); - if (modifierList == null) { - return true; - } - return !modifierList.hasModifierProperty("static"); - } - }), - new Function() { - @Nullable @Override public Field apply(@Nullable PsiField psiField) { - return new SmalideaField(psiField); - } - }); - } - - @Nonnull @Override public Iterable getFields() { - return Iterables.concat(getStaticFields(), getInstanceFields()); - } - - @Nonnull @Override public Iterable getDirectMethods() { - return Iterables.transform( - Iterables.filter( - Iterables.concat( - Arrays.asList(psiClass.getConstructors()), - Arrays.asList(psiClass.getMethods())), - new Predicate() { - @Override public boolean apply(PsiMethod psiMethod) { - PsiModifierList modifierList = psiMethod.getModifierList(); - return modifierList.hasModifierProperty("static") || - modifierList.hasModifierProperty("private") || - modifierList.hasModifierProperty("constructor"); - } - }), - new Function() { - @Nullable @Override public Method apply(PsiMethod psiMethod) { - return new SmalideaMethod(psiMethod); - } - }); - } - - @Nonnull @Override public Iterable getVirtualMethods() { - return Iterables.transform( - Iterables.filter(Arrays.asList(psiClass.getMethods()), new Predicate() { - @Override public boolean apply(PsiMethod psiMethod) { - PsiModifierList modifierList = psiMethod.getModifierList(); - return !modifierList.hasModifierProperty("static") && - !modifierList.hasModifierProperty("private") && - !modifierList.hasModifierProperty("constructor"); - } - }), - new Function() { - @Nullable @Override public Method apply(PsiMethod psiMethod) { - return new SmalideaMethod(psiMethod); - } - }); - } - - @Nonnull @Override public Iterable getMethods() { - return Iterables.concat(getDirectMethods(), getVirtualMethods()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaExceptionHandler.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaExceptionHandler.java deleted file mode 100644 index 72909b63..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaExceptionHandler.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaField.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaField.java deleted file mode 100644 index 7b98174a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaField.java +++ /dev/null @@ -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 getAnnotations() { - // TODO: implement this. Not needed for method analysis - return ImmutableSet.of(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethod.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethod.java deleted file mode 100644 index abc4dda8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethod.java +++ /dev/null @@ -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 getParameters() { - PsiParameter[] parameters = psiMethod.getParameterList().getParameters(); - - return Lists.transform(Arrays.asList(parameters), new Function() { - @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 getAnnotations() { - // TODO: implement this - return ImmutableSet.of(); - } - - @Nullable @Override public MethodImplementation getImplementation() { - if (psiMethod instanceof SmaliMethod) { - final SmaliMethod smaliMethod = (SmaliMethod)this.psiMethod; - - List 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 getInstructions() { - return Lists.transform(smaliMethod.getInstructions(), - new Function() { - @Override - public Instruction apply(SmaliInstruction smaliInstruction) { - return SmalideaInstruction.of(smaliInstruction); - } - }); - } - - @Nonnull @Override public List> getTryBlocks() { - return Lists.transform(smaliMethod.getCatchStatements(), - new Function>() { - @Override - public TryBlock apply( - SmaliCatchStatement smaliCatchStatement) { - assert smaliCatchStatement != null; - return new SmalideaTryBlock(smaliCatchStatement); - } - }); - } - - @Nonnull @Override public Iterable getDebugItems() { - // TODO: implement this - return ImmutableList.of(); - } - }; - } - return null; - } - - @Nonnull @Override public String getName() { - return psiMethod.getName(); - } - - @Nonnull @Override public List getParameterTypes() { - PsiParameter[] parameters = psiMethod.getParameterList().getParameters(); - - return Lists.transform(Arrays.asList(parameters), new Function() { - @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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethodParameter.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethodParameter.java deleted file mode 100644 index 49d75c83..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaMethodParameter.java +++ /dev/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; - -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 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()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaTryBlock.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaTryBlock.java deleted file mode 100644 index 6fbab593..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/SmalideaTryBlock.java +++ /dev/null @@ -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 { - @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 getExceptionHandlers() { - return Arrays.asList(new SmalideaExceptionHandler(catchStatement)); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/analysis/SmalideaClassProvider.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/analysis/SmalideaClassProvider.java deleted file mode 100644 index 9d2a14ac..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/analysis/SmalideaClassProvider.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaArrayPayload.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaArrayPayload.java deleted file mode 100644 index 26f2daf7..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaArrayPayload.java +++ /dev/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 getArrayElements() { - return Lists.transform(psiInstruction.getArrayDataElements(), new Function() { - @Nullable @Override public Number apply(SmaliArrayDataElement smaliArrayDataElement) { - return smaliArrayDataElement.getValue().getIntegralValue(); - } - }); - } - - @Override public int getCodeUnits() { - return psiInstruction.getInstructionSize()/2; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction.java deleted file mode 100644 index b5b259a2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction.java +++ /dev/null @@ -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 paramTypes = - Lists.transform(methodReference.getParameterTypes(), new Function() { - @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; - } - -} \ No newline at end of file diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10t.java deleted file mode 100644 index 80a4ba66..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10x.java deleted file mode 100644 index 04804514..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction10x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11n.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11n.java deleted file mode 100644 index 1b185dd8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11n.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11x.java deleted file mode 100644 index 7e8fbf4d..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction11x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction12x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction12x.java deleted file mode 100644 index c6cba0a7..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction12x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction20t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction20t.java deleted file mode 100644 index 1c0a9216..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction20t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21c.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21c.java deleted file mode 100644 index f2ac6f1a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21c.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21ih.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21ih.java deleted file mode 100644 index ce5f598f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21ih.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21lh.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21lh.java deleted file mode 100644 index 3ef08505..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21lh.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21s.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21s.java deleted file mode 100644 index 5ae75060..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21s.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21t.java deleted file mode 100644 index 11e17564..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction21t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22b.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22b.java deleted file mode 100644 index f1360467..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22b.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22c.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22c.java deleted file mode 100644 index 4d7dacbe..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22c.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22s.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22s.java deleted file mode 100644 index 81897688..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22s.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22t.java deleted file mode 100644 index 8f4811d9..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22x.java deleted file mode 100644 index 5cc8b004..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction22x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction23x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction23x.java deleted file mode 100644 index 3cc60d89..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction23x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction30t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction30t.java deleted file mode 100644 index 324fc773..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction30t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31c.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31c.java deleted file mode 100644 index ffea2175..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31c.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31i.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31i.java deleted file mode 100644 index 0fef6674..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31i.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31t.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31t.java deleted file mode 100644 index 142fd446..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction31t.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction32x.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction32x.java deleted file mode 100644 index 1ac27deb..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction32x.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction35c.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction35c.java deleted file mode 100644 index a3ddcce0..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction35c.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction3rc.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction3rc.java deleted file mode 100644 index 509e6b75..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction3rc.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction51l.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction51l.java deleted file mode 100644 index 3b58628b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaInstruction51l.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaPackedSwitchPayload.java b/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaPackedSwitchPayload.java deleted file mode 100644 index 6056da37..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/dexlib/instruction/SmalideaPackedSwitchPayload.java +++ /dev/null @@ -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 getSwitchElements() { - final SmaliLiteral startKey = psiInstruction.getPackedSwitchStartKey(); - assert startKey != null; - List 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 newElements = Lists.newArrayList(); - // TODO: check for integer wraparound (how does art/dalvik handle that?) - int initialKey = (int)startKey.getIntegralValue(); - for (int i=0; i getSwitchElements() { - List 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() { - @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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/errorReporting/ErrorReporter.java b/smalidea/src/main/java/org/jf/smalidea/errorReporting/ErrorReporter.java deleted file mode 100644 index 92aef72b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/errorReporting/ErrorReporter.java +++ /dev/null @@ -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 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 reportValues = ITNProxy.createParameters(bean); - - final Project project = CommonDataKeys.PROJECT.getData(dataContext); - - Consumer successCallback = new Consumer() { - @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 errorCallback = new Consumer() { - @Override - public void consume(Exception e) { - String message = String.format("There was an error while creating a GitHub issue: %s
" + - "Please consider manually creating an issue on the " + - "Smali Issue Tracker", - 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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/errorReporting/GithubFeedbackTask.java b/smalidea/src/main/java/org/jf/smalidea/errorReporting/GithubFeedbackTask.java deleted file mode 100644 index ab54dc6b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/errorReporting/GithubFeedbackTask.java +++ /dev/null @@ -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 myCallback; - private final Consumer myErrorCallback; - private final Map myParams; - - public GithubFeedbackTask(@Nullable Project project, - @NotNull String title, - boolean canBeCancelled, - Map params, - final Consumer callback, - final Consumer 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 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 environmentDetails) { - LinkedHashMap result = new LinkedHashMap(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 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 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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/errorReporting/ITNProxy.java b/smalidea/src/main/java/org/jf/smalidea/errorReporting/ITNProxy.java deleted file mode 100644 index 5bf93e32..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/errorReporting/ITNProxy.java +++ /dev/null @@ -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 createParameters(ErrorBean error) { - Map 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()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliClassReferenceSearcher.java b/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliClassReferenceSearcher.java deleted file mode 100644 index 63e4d6fe..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliClassReferenceSearcher.java +++ /dev/null @@ -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 { - @Override public void processQuery(final SearchParameters queryParameters, final Processor consumer) { - final PsiElement element = queryParameters.getElementToSearch(); - if (!(element instanceof PsiClass)) { - return; - } - - String smaliType = ApplicationManager.getApplication().runReadAction( - new Computable() { - @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() { - @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() { - @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; - } - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliFindUsagesProvider.java b/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliFindUsagesProvider.java deleted file mode 100644 index 335bce27..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliFindUsagesProvider.java +++ /dev/null @@ -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(); - } - - -} diff --git a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTargetProvider.java b/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTargetProvider.java deleted file mode 100644 index e87782b6..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTargetProvider.java +++ /dev/null @@ -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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTypeProvider.java b/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTypeProvider.java deleted file mode 100644 index ad869421..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliUsageTypeProvider.java +++ /dev/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 newArrayInstructions = EnumSet.of(Opcode.FILLED_NEW_ARRAY, Opcode.NEW_ARRAY, - Opcode.FILLED_NEW_ARRAY_RANGE); - - private final Set 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 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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliWordScanner.java b/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliWordScanner.java deleted file mode 100644 index 56bbdafb..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/findUsages/SmaliWordScanner.java +++ /dev/null @@ -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 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 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)); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementFactory.java b/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementFactory.java deleted file mode 100644 index 6d5bb105..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementFactory.java +++ /dev/null @@ -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(); -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementType.java deleted file mode 100644 index ae5fc538..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliCompositeElementType.java +++ /dev/null @@ -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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliElementTypes.java b/smalidea/src/main/java/org/jf/smalidea/psi/SmaliElementTypes.java deleted file mode 100644 index bb4bd37a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/SmaliElementTypes.java +++ /dev/null @@ -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); -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/iface/SmaliModifierListOwner.java b/smalidea/src/main/java/org/jf/smalidea/psi/iface/SmaliModifierListOwner.java deleted file mode 100644 index 3da47c9b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/iface/SmaliModifierListOwner.java +++ /dev/null @@ -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(); -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/LightSmaliClassTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/LightSmaliClassTypeElement.java deleted file mode 100644 index acd9a02a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/LightSmaliClassTypeElement.java +++ /dev/null @@ -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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotation.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotation.java deleted file mode 100644 index ac3dd81f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotation.java +++ /dev/null @@ -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 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 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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElement.java deleted file mode 100644 index 10784f8f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElement.java +++ /dev/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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElementName.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElementName.java deleted file mode 100644 index 656b4eff..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationElementName.java +++ /dev/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; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationParameterList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationParameterList.java deleted file mode 100644 index 7feaa9ee..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliAnnotationParameterList.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayDataElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayDataElement.java deleted file mode 100644 index 85f62138..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayDataElement.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayTypeElement.java deleted file mode 100644 index 1b54a9c0..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliArrayTypeElement.java +++ /dev/null @@ -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); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliBaseReferenceList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliBaseReferenceList.java deleted file mode 100644 index b47d5126..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliBaseReferenceList.java +++ /dev/null @@ -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 - extends SmaliStubBasedPsiElement implements StubBasedPsiElement, 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 implements PsiClass, SmaliModifierListOwner { - public SmaliClass(@NotNull SmaliClassStub stub) { - super(stub, SmaliElementTypes.CLASS); - } - - public SmaliClass(@NotNull ASTNode node) { - super(node); - } - - @Nonnull - @Override - public String getName() { - String name = getQualifiedName(); - if (name == null) { - return ""; - } - int lastDot = name.lastIndexOf('.'); - if (lastDot < 0) { - return name; - } - return name.substring(lastDot+1); - } - - @Override public ItemPresentation getPresentation() { - return ItemPresentationProviders.getItemPresentation(this); - } - - @Nullable @Override public String getQualifiedName() { - SmaliClassStatement classStatement = getStubOrPsiChild(SmaliElementTypes.CLASS_STATEMENT); - if (classStatement == null) { - return null; - } - return classStatement.getQualifiedName(); - } - - @NotNull public String getPackageName() { - String name = getQualifiedName(); - if (name == null) { - return ""; - } - int lastDot = name.lastIndexOf('.'); - if (lastDot < 0) { - return ""; - } - return name.substring(0, lastDot); - } - - @Override public boolean hasTypeParameters() { - // TODO: implement generics - return false; - } - - @Override public boolean isInterface() { - return hasModifierProperty("interface"); - } - - @Override public boolean isAnnotationType() { - return hasModifierProperty("annotation"); - } - - @Override public boolean isEnum() { - return hasModifierProperty("enum"); - } - - @Nullable public SmaliSuperStatement getSuperStatement() { - return findChildByClass(SmaliSuperStatement.class); - } - - @NotNull @Override public SmaliExtendsList getExtendsList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.EXTENDS_LIST); - } - - @NotNull public SmaliImplementsStatement[] getImplementsStatements() { - return findChildrenByClass(SmaliImplementsStatement.class); - } - - @NotNull @Override public SmaliImplementsList getImplementsList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.IMPLEMENTS_LIST); - } - - @NotNull @Override public SmaliClassType[] getExtendsListTypes() { - return getExtendsList().getReferencedTypes(); - } - - @NotNull @Override public SmaliClassType[] getImplementsListTypes() { - return getImplementsList().getReferencedTypes(); - } - - @Nullable @Override public PsiClass getSuperClass() { - return PsiClassImplUtil.getSuperClass(this); - } - - @Override public PsiClass[] getInterfaces() { - return PsiClassImplUtil.getInterfaces(this); - } - - @NotNull @Override public PsiClass[] getSupers() { - return PsiClassImplUtil.getSupers(this); - } - - @NotNull @Override public PsiClassType[] getSuperTypes() { - return PsiClassImplUtil.getSuperTypes(this); - } - - @NotNull @Override public SmaliField[] getFields() { - SmaliField[] fields = getStubOrPsiChildren(SmaliElementTypes.FIELD, new SmaliField[0]); - List filteredFields = null; - for (int i=fields.length-1; i>=0; i--) { - SmaliField field = fields[i]; - if (field.getName() == null) { - if (filteredFields == null) { - filteredFields = Lists.newArrayList(fields); - } - filteredFields.remove(i); - } - } - if (filteredFields != null) { - return filteredFields.toArray(new SmaliField[filteredFields.size()]); - } - return fields; - } - - @NotNull @Override public SmaliMethod[] getMethods() { - return getStubOrPsiChildren(SmaliElementTypes.METHOD, new SmaliMethod[0]); - } - - @NotNull @Override public PsiMethod[] getConstructors() { - return PsiImplUtil.getConstructors(this); - } - - @NotNull @Override public PsiClass[] getInnerClasses() { - return new PsiClass[0]; - } - - @NotNull @Override public PsiClassInitializer[] getInitializers() { - // TODO: do we need to return the method here? - return new PsiClassInitializer[0]; - } - - @NotNull @Override public PsiField[] getAllFields() { - return PsiClassImplUtil.getAllFields(this); - } - - @NotNull @Override public PsiMethod[] getAllMethods() { - return PsiClassImplUtil.getAllMethods(this); - } - - @NotNull @Override public PsiClass[] getAllInnerClasses() { - return new PsiClass[0]; - } - - @Nullable @Override public PsiField findFieldByName(@NonNls String name, boolean checkBases) { - return PsiClassImplUtil.findFieldByName(this, name, checkBases); - } - - @Nullable @Override public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) { - return PsiClassImplUtil.findMethodBySignature(this, patternMethod, checkBases); - } - - @NotNull @Override public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) { - return PsiClassImplUtil.findMethodsBySignature(this, patternMethod, checkBases); - } - - @NotNull @Override public PsiMethod[] findMethodsByName(@NonNls String name, boolean checkBases) { - return PsiClassImplUtil.findMethodsByName(this, name, checkBases); - } - - @NotNull @Override - public List> findMethodsAndTheirSubstitutorsByName(@NonNls String name, boolean checkBases) { - return PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases); - } - - @NotNull @Override public List> getAllMethodsAndTheirSubstitutors() { - return PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiClassImplUtil.MemberType.METHOD); - } - - @Nullable @Override public PsiClass findInnerClassByName(@NonNls String name, boolean checkBases) { - return null; - } - - @Nullable @Override public PsiElement getLBrace() { - return null; - } - - @Nullable @Override public PsiElement getRBrace() { - return null; - } - - @Nullable public SmaliClassStatement getClassStatement() { - return getStubOrPsiChild(SmaliElementTypes.CLASS_STATEMENT); - } - - @Nullable @Override public SmaliClassDescriptor getNameIdentifier() { - SmaliClassStatement classStatement = getClassStatement(); - if (classStatement == null) { - return null; - } - return classStatement.getNameIdentifier(); - } - - @Override public PsiElement getScope() { - return null; - } - - @Override public boolean isInheritor(@NotNull PsiClass baseClass, boolean checkDeep) { - return InheritanceImplUtil.isInheritor(this, baseClass, checkDeep); - } - - @Override public boolean isInheritorDeep(PsiClass baseClass, @Nullable PsiClass classToByPass) { - return InheritanceImplUtil.isInheritorDeep(this, baseClass, classToByPass); - } - - @Nullable @Override public PsiClass getContainingClass() { - return null; - } - - @NotNull @Override public Collection getVisibleSignatures() { - return ImmutableList.of(); - } - - @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - SmaliClassStatement classStatement = getClassStatement(); - if (classStatement == null) { - throw new IncorrectOperationException(); - } - - SmaliClassTypeElement classTypeElement = classStatement.getNameElement(); - if (classTypeElement == null) { - throw new IncorrectOperationException(); - } - - String expectedPath = "/" + getName() + ".smali"; - - VirtualFile virtualFile = this.getContainingFile().getVirtualFile(); - if (virtualFile != null) { - String actualPath = virtualFile.getPath(); - if (actualPath.endsWith(expectedPath)) { - getContainingFile().setName(name + ".smali"); - } - } - - String packageName = this.getPackageName(); - String newName; - if (packageName.length() > 0) { - newName = packageName + "." + name; - } else { - newName = name; - } - classTypeElement.handleElementRename(newName); - return this; - } - - public void setPackageName(@NonNls @NotNull String packageName) { - SmaliClassStatement classStatement = getClassStatement(); - if (classStatement == null) { - throw new IncorrectOperationException(); - } - - SmaliClassTypeElement classTypeElement = classStatement.getNameElement(); - if (classTypeElement == null) { - throw new IncorrectOperationException(); - } - - String newName; - if (packageName.length() > 0) { - newName = packageName + "." + getName(); - } else { - newName = getName(); - } - - classTypeElement.handleElementRename(newName); - } - - @Nullable @Override public PsiDocComment getDocComment() { - return null; - } - - @Override public boolean isDeprecated() { - return false; - } - - @Nullable @Override public PsiTypeParameterList getTypeParameterList() { - return null; - } - - @NotNull @Override public PsiTypeParameter[] getTypeParameters() { - return new PsiTypeParameter[0]; - } - - @Nullable @Override public SmaliModifierList getModifierList() { - SmaliClassStatement classStatement = getStubOrPsiChild(SmaliElementTypes.CLASS_STATEMENT); - if (classStatement == null) { - return null; - } - return classStatement.getModifierList(); - } - - @Override public boolean hasModifierProperty(@ModifierConstant @NonNls @NotNull String name) { - SmaliModifierList smaliModifierList = getModifierList(); - return smaliModifierList != null && smaliModifierList.hasModifierProperty(name); - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - return getStubOrPsiChildren(SmaliElementTypes.ANNOTATION, new SmaliAnnotation[0]); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - for (SmaliAnnotation annotation: getAnnotations()) { - if (qualifiedName.equals(annotation.getQualifiedName())) { - return annotation; - } - } - return null; - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - // TODO: implement this - return null; - } - - @Nullable public Location getLocationForSourcePosition(@Nonnull ReferenceType type, - @Nonnull SourcePosition position) { - - SmaliMethod[] smaliMethods = findChildrenByType(SmaliElementTypes.METHOD, SmaliMethod.class); - - for (SmaliMethod smaliMethod: smaliMethods) { - //TODO: check the start line+end line of the method - int offset = smaliMethod.getOffsetForLine(position.getLine()); - if (offset != -1) { - List methods = type.methodsByName(smaliMethod.getName(), - smaliMethod.getMethodPrototype().getText()); - if (methods.size() > 0) { - return methods.get(0).locationOfCodeIndex(offset/2); - } - } - } - return null; - } - - @Override - public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, - PsiElement lastParent, @NotNull PsiElement place) { - return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, - PsiUtil.getLanguageLevel(place), false); - } - - @Nullable @Override protected Icon getElementIcon(@IconFlags int flags) { - return SmaliIcons.SmaliIcon; - } -} \ No newline at end of file diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassStatement.java deleted file mode 100644 index add3c1b2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassStatement.java +++ /dev/null @@ -1,146 +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 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.iface.SmaliModifierListOwner; -import org.jf.smalidea.psi.leaf.SmaliClassDescriptor; -import org.jf.smalidea.psi.stub.SmaliClassStatementStub; -import org.jf.smalidea.util.NameUtils; - -public class SmaliClassStatement extends SmaliStubBasedPsiElement - implements SmaliModifierListOwner { - public SmaliClassStatement(@NotNull SmaliClassStatementStub stub) { - super(stub, SmaliElementTypes.CLASS_STATEMENT); - } - - public SmaliClassStatement(@NotNull ASTNode node) { - super(node); - } - - @Nullable - public SmaliClassTypeElement getNameElement() { - return findChildByClass(SmaliClassTypeElement.class); - } - - @Nullable - public SmaliClass getContainingClass() { - return getStubOrPsiParentOfType(SmaliClass.class); - } - - @Nullable - public SmaliClassDescriptor getNameIdentifier() { - SmaliClassTypeElement classTypeElement = getNameElement(); - if (classTypeElement == null) { - return null; - } - return classTypeElement.getReferenceNameElement(); - } - - /** - * @return the fully qualified java-style name of the class in this .class statement - */ - @Nullable - public String getQualifiedName() { - SmaliClassStatementStub stub = getStub(); - if (stub != null) { - return stub.getQualifiedName(); - } - - SmaliClassTypeElement classType = findChildByClass(SmaliClassTypeElement.class); - if (classType == null) { - return null; - } - // Since this is a class declared in smali, we don't have to worry about handling inner classes, - // so we can do a pure textual translation of the class name - return NameUtils.smaliToJavaType(classType.getSmaliName()); - } - - @Nullable - public SmaliModifierList getModifierList() { - return getStubOrPsiChild(SmaliElementTypes.MODIFIER_LIST); - } - - @NotNull - @Override - public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null) { - // TODO: what should we do here? - return null; - } - return containingClass.addAnnotation(qualifiedName); - } - - @NotNull - @Override - public SmaliAnnotation[] getAnnotations() { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null) { - return new SmaliAnnotation[0]; - } - return containingClass.getAnnotations(); - } - - @NotNull - @Override - public SmaliAnnotation[] getApplicableAnnotations() { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null) { - return new SmaliAnnotation[0]; - } - return containingClass.getApplicableAnnotations(); - } - - @Nullable - @Override - public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null) { - return null; - } - return containingClass.findAnnotation(qualifiedName); - } - - @Override - public boolean hasModifierProperty(@NonNls @NotNull String name) { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null) { - return false; - } - return containingClass.hasModifierProperty(name); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassType.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassType.java deleted file mode 100644 index 6d5bbaba..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassType.java +++ /dev/null @@ -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.psi.impl; - -import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.util.NameUtils; - -public class SmaliClassType extends PsiClassType { - private final PsiTypeElement element; - - public SmaliClassType(PsiTypeElement element) { - this(element, LanguageLevel.JDK_1_5); - } - - public SmaliClassType(PsiTypeElement element, LanguageLevel languageLevel) { - super(languageLevel); - this.element = element; - } - - @Nullable - @Override - public PsiClass resolve() { - PsiReference reference = element.getReference(); - if (reference == null) { - return null; - } - PsiElement resolved = reference.resolve(); - if (resolved instanceof PsiClass) { - return (PsiClass)resolved; - } - return null; - } - - @Override - public String getClassName() { - PsiClass resolved = resolve(); - if (resolved != null) { - return NameUtils.shortNameFromQualifiedName(resolved.getQualifiedName()); - } - return NameUtils.shortNameFromQualifiedName(element.getText()); - } - - @NotNull - @Override - public PsiType[] getParameters() { - // TODO: (generics) implement this - return PsiType.EMPTY_ARRAY; - } - - @NotNull - @Override - public ClassResolveResult resolveGenerics() { - // TODO: (generics) implement this - return new ClassResolveResult() { - @Override - public PsiClass getElement() { - return resolve(); - } - - @Override - public PsiSubstitutor getSubstitutor() { - return PsiSubstitutor.EMPTY; - } - - @Override - public boolean isPackagePrefixPackageReference() { - return false; - } - - @Override - public boolean isAccessible() { - return true; - } - - @Override - public boolean isStaticsScopeCorrect() { - return true; - } - - @Override - public PsiElement getCurrentFileResolveScope() { - return null; - } - - @Override - public boolean isValidResult() { - return true; - } - }; - } - - @NotNull - @Override - public SmaliClassType rawType() { - // TODO: (generics) implement this - return this; - } - - @Override - @NotNull - public String getPresentableText() { - return getCanonicalText(); - } - - @Override - @NotNull - public String getCanonicalText() { - PsiClass psiClass = resolve(); - if (psiClass != null) { - String qualifiedName = psiClass.getQualifiedName(); - if (qualifiedName != null) { - return qualifiedName; - } - } - return NameUtils.smaliToJavaType(element.getText()); - } - - @Override - @NotNull - public String getInternalCanonicalText() { - return getCanonicalText(); - } - - @Override - public boolean isValid() { - return element.isValid(); - } - - @Override - public boolean equalsToText(@NonNls String text) { - return text.equals(getCanonicalText()); - } - - @NotNull - @Override - public GlobalSearchScope getResolveScope() { - return element.getResolveScope(); - } - - @NotNull - @Override - public LanguageLevel getLanguageLevel() { - return myLanguageLevel; - } - - @NotNull - @Override - public PsiClassType setLanguageLevel(@NotNull LanguageLevel languageLevel) { - return new SmaliClassType(element, languageLevel); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassTypeElement.java deleted file mode 100644 index b491f6df..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliClassTypeElement.java +++ /dev/null @@ -1,192 +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.source.codeStyle.CodeEditUtil; -import com.intellij.psi.infos.CandidateInfo; -import com.intellij.psi.scope.PsiScopeProcessor; -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; -import org.jf.smalidea.psi.leaf.SmaliClassDescriptor; -import org.jf.smalidea.util.NameUtils; - -public class SmaliClassTypeElement extends SmaliTypeElement implements PsiJavaCodeReferenceElement { - public static final SmaliClassTypeElement[] EMPTY_ARRAY = new SmaliClassTypeElement[0]; - - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliClassTypeElement(); - } - }; - - @Nullable private SmaliClassType classType = null; - - public SmaliClassTypeElement() { - super(SmaliElementTypes.CLASS_TYPE); - } - - @NotNull @Override public SmaliClassType getType() { - if (classType == null) { - classType = new SmaliClassType(this); - } - return classType; - } - - @Override public String getName() { - return NameUtils.shortNameFromQualifiedName(getCanonicalText()); - } - - @Nullable @Override public SmaliClassTypeElement getInnermostComponentReferenceElement() { - return this; - } - - @Override public PsiElement getElement() { - return this; - } - - @Override public PsiReference getReference() { - return this; - } - - @Override public TextRange getRangeInElement() { - return new TextRange(0, getTextLength()); - } - - @Nullable @Override public PsiClass resolve() { - return NameUtils.resolveSmaliType(this, getText()); - } - - @NotNull @Override public String getCanonicalText() { - return getQualifiedName(); - } - - @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { - SmaliClassDescriptor descriptor = getReferenceNameElement(); - if (descriptor == null) { - throw new IncorrectOperationException(); - } - - SmaliClassDescriptor newDescriptor = new SmaliClassDescriptor(NameUtils.javaToSmaliType(newElementName)); - CodeEditUtil.setNodeGenerated(newDescriptor, true); - - this.replaceChild(descriptor, newDescriptor); - return this; - } - - @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { - if (element instanceof PsiClass) { - handleElementRename(((PsiClass) element).getQualifiedName()); - return this; - } - throw new IncorrectOperationException(); - } - - @Override public boolean isReferenceTo(PsiElement element) { - if (!(element instanceof PsiClass)) { - return false; - } - return element.getManager().areElementsEquivalent(element, resolve()); - } - - @NotNull @Override public Object[] getVariants() { - // TODO: implement this? - return new Object[0]; - } - - @Override public boolean isSoft() { - return false; - } - - // *************************************************************************** - // Below are the PsiJavaCodeReferenceElement-specific methods - - @Override public void processVariants(@NotNull PsiScopeProcessor processor) { - // TODO: maybe just do nothing? - throw new UnsupportedOperationException(); - } - - @Nullable @Override public SmaliClassDescriptor getReferenceNameElement() { - return findChildByClass(SmaliClassDescriptor.class); - } - - @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() { - PsiClass psiClass = resolve(); - if (psiClass != null) { - return psiClass.getQualifiedName(); - } - return NameUtils.smaliToJavaType(getText()); - } - - @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() { - return null; - } - - @Nullable @Override public String getReferenceName() { - return getName(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliCompositeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliCompositeElement.java deleted file mode 100644 index d9c38c4e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliCompositeElement.java +++ /dev/null @@ -1,127 +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.google.common.collect.ImmutableList; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.source.tree.CompositePsiElement; -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.List; - -public abstract class SmaliCompositeElement extends CompositePsiElement { - public SmaliCompositeElement(IElementType type) { - super(type); - } - - @NotNull - @SuppressWarnings("unchecked") - protected List findChildrenByType(IElementType elementType) { - List result = ImmutableList.of(); - ASTNode child = getNode().getFirstChildNode(); - while (child != null) { - if (elementType == child.getElementType()) { - if (result.size() == 0) { - result = new ArrayList(); - } - result.add((ASTNode)child.getPsi()); - } - child = child.getTreeNext(); - } - return result; - } - - @NotNull - @SuppressWarnings("unchecked") - protected T[] findChildrenByClass(Class aClass) { - List result = new ArrayList(); - for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { - if (aClass.isInstance(cur)) result.add((T)cur); - } - return result.toArray((T[]) Array.newInstance(aClass, result.size())); - } - - @Nullable - @SuppressWarnings("unchecked") - protected T findChildByClass(Class aClass) { - for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { - if (aClass.isInstance(cur)) return (T)cur; - } - return null; - } - - @Nullable - @SuppressWarnings("unchecked") - protected T findAncestorByClass(Class aClass) { - PsiElement parent = getParent(); - while (parent != null) { - if (aClass.isInstance(parent)) { - return (T)parent; - } - parent = parent.getParent(); - } - return null; - } - - @Nullable - @SuppressWarnings("unchecked") - public T findNextSiblingByClass(@NotNull Class cls) { - PsiElement prev = getNextSibling(); - while (true) { - if (prev == null) { - return null; - } else if (cls.isInstance(prev)) { - return (T)prev; - } - prev = prev.getNextSibling(); - } - } - - @Nullable - @SuppressWarnings("unchecked") - public T findPrevSiblingByClass(@NotNull Class cls) { - PsiElement prev = getPrevSibling(); - while (true) { - if (prev == null) { - return null; - } else if (cls.isInstance(prev)) { - return (T)prev; - } - prev = prev.getPrevSibling(); - } - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEndLocalDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEndLocalDebugStatement.java deleted file mode 100644 index 042596cf..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEndLocalDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliEndLocalDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliEndLocalDebugStatement(); - } - }; - - public SmaliEndLocalDebugStatement() { - super(SmaliElementTypes.END_LOCAL_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEpilogueDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEpilogueDebugStatement.java deleted file mode 100644 index faaef090..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliEpilogueDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliEpilogueDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliEpilogueDebugStatement(); - } - }; - - public SmaliEpilogueDebugStatement() { - super(SmaliElementTypes.EPILOGUE_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliExtendsList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliExtendsList.java deleted file mode 100644 index ace9a976..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliExtendsList.java +++ /dev/null @@ -1,96 +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.google.common.collect.Lists; -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.stub.SmaliExtendsListStub; - -import java.util.List; - -public class SmaliExtendsList extends SmaliBaseReferenceList { - public SmaliExtendsList(@NotNull SmaliExtendsListStub stub) { - super(stub, SmaliElementTypes.EXTENDS_LIST); - } - - public SmaliExtendsList(@NotNull ASTNode node) { - super(node); - } - - @NotNull @Override public SmaliClassTypeElement[] getReferenceElements() { - if (((SmaliClass)getParent()).isInterface()) { - return getImplementsElements(); - } else { - return getExtendsElement(); - } - } - - @NotNull private SmaliClassTypeElement[] getImplementsElements() { - SmaliClass smaliClass = getStubOrPsiParentOfType(SmaliClass.class); - assert smaliClass != null; - - SmaliImplementsStatement[] implementsStatements = smaliClass.getImplementsStatements(); - if (implementsStatements.length > 0) { - // all implemented interfaces go in the extends list for an interface - List types = Lists.newArrayList(); - - for (SmaliImplementsStatement implementsStatement: implementsStatements) { - SmaliClassTypeElement classReference = implementsStatement.getClassReference(); - if (classReference != null) { - types.add(classReference); - } - } - return types.toArray(new SmaliClassTypeElement[types.size()]); - } - return new SmaliClassTypeElement[0]; - } - - @NotNull private SmaliClassTypeElement[] getExtendsElement() { - SmaliClass smaliClass = getStubOrPsiParentOfType(SmaliClass.class); - assert smaliClass != null; - - SmaliSuperStatement superStatement = smaliClass.getSuperStatement(); - if (superStatement != null) { - SmaliClassTypeElement classReference = superStatement.getClassReference(); - if (classReference != null) { - return new SmaliClassTypeElement[] { classReference }; - } - } - return new SmaliClassTypeElement[0]; - } - - @Override public Role getRole() { - return Role.EXTENDS_LIST; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliField.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliField.java deleted file mode 100644 index 579401cf..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliField.java +++ /dev/null @@ -1,174 +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.PsiModifier.ModifierConstant; -import com.intellij.psi.impl.PsiImplUtil; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.util.IncorrectOperationException; -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.iface.SmaliModifierListOwner; -import org.jf.smalidea.psi.stub.SmaliFieldStub; -import org.jf.smalidea.util.NameUtils; - -public class SmaliField extends SmaliStubBasedPsiElement implements PsiField, SmaliModifierListOwner { - public SmaliField(@NotNull SmaliFieldStub stub) { - super(stub, SmaliElementTypes.FIELD); - } - - public SmaliField(@NotNull ASTNode node) { - super(node); - } - - @Nullable @Override public String getName() { - SmaliFieldStub stub = getStub(); - if (stub != null) { - return stub.getName(); - } - - SmaliMemberName smaliMemberName = findChildByClass(SmaliMemberName.class); - if (smaliMemberName == null || smaliMemberName.getText().isEmpty()) { - return null; - } - return smaliMemberName.getText(); - } - - @NotNull @Override public SmaliModifierList getModifierList() { - SmaliModifierList modifierList = getStubOrPsiChild(SmaliElementTypes.MODIFIER_LIST); - assert modifierList != null; - return modifierList; - } - - @NotNull @Override public SmaliMemberName getNameIdentifier() { - SmaliMemberName memberName = findChildByClass(SmaliMemberName.class); - assert memberName != null; - return memberName; - } - - @Nullable @Override public PsiDocComment getDocComment() { - return null; - } - - @Override public boolean isDeprecated() { - return PsiImplUtil.isDeprecatedByAnnotation(this); - } - - @Nullable @Override public PsiClass getContainingClass() { - return (PsiClass)getParentByStub(); - } - - @NotNull @Override public PsiType getType() { - SmaliFieldStub stub = getStub(); - if (stub != null) { - return NameUtils.resolveSmaliToPsiType(this, stub.getSmaliTypeName()); - } - PsiTypeElement typeElement = getTypeElement(); - if (typeElement == null) { - // If we don't have a type (i.e. syntax error), use Object as a safe-ish fallback - PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); - return factory.createTypeFromText("java.lang.Object", this); - } - return getTypeElement().getType(); - } - - @Nullable @Override public SmaliTypeElement getTypeElement() { - return findChildByClass(SmaliTypeElement.class); - } - - @Nullable @Override public PsiExpression getInitializer() { - // TODO: implement this - return null; - } - - @Override public boolean hasInitializer() { - // TODO: implement this - return false; - } - - @Override public void normalizeDeclaration() throws IncorrectOperationException { - // not applicable - } - - @Nullable @Override public Object computeConstantValue() { - // TODO: implement this - return null; - } - - @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - SmaliMemberName smaliMemberName = getNameIdentifier(); - smaliMemberName.setName(name); - return this; - } - - @Override public boolean hasModifierProperty(@ModifierConstant @NonNls @NotNull String name) { - return getModifierList().hasModifierProperty(name); - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - return getStubOrPsiChildren(SmaliElementTypes.ANNOTATION, new SmaliAnnotation[0]); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - for (SmaliAnnotation annotation: getAnnotations()) { - if (qualifiedName.equals(annotation.getQualifiedName())) { - return annotation; - } - } - return null; - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - // TODO: implement this - return null; - } - - @Override public void setInitializer(@Nullable PsiExpression initializer) throws IncorrectOperationException { - // TODO: implement this - } - - @Override public int getTextOffset() { - SmaliMemberName smaliMemberName = getNameIdentifier(); - if (smaliMemberName != null) { - return smaliMemberName.getTextOffset(); - } - return super.getTextOffset(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldInitializer.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldInitializer.java deleted file mode 100644 index dcf0e858..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldInitializer.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliFieldInitializer extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliFieldInitializer(); - } - }; - - public SmaliFieldInitializer() { - super(SmaliElementTypes.FIELD_INITIALIZER); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldReference.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldReference.java deleted file mode 100644 index 0626c3a2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFieldReference.java +++ /dev/null @@ -1,151 +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.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiReference; -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 SmaliFieldReference extends SmaliCompositeElement implements PsiReference { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliFieldReference(); - } - }; - - public SmaliFieldReference() { - super(SmaliElementTypes.FIELD_REFERENCE); - } - - @Nullable - public PsiClass getContainingClass() { - SmaliClassTypeElement containingClassReference = getContainingType(); - if (containingClassReference == null) { - return null; - } - PsiClass containingClass = containingClassReference.resolve(); - if (containingClass == null) { - return null; - } - - return containingClass; - } - - @Nullable - public SmaliClassTypeElement getContainingType() { - return findChildByClass(SmaliClassTypeElement.class); - } - - @Nullable - public SmaliMemberName getMemberName() { - return findChildByClass(SmaliMemberName.class); - } - - @Nullable - public SmaliTypeElement getFieldType() { - SmaliTypeElement[] types = findChildrenByClass(SmaliTypeElement.class); - assert types.length == 2; - return types[1]; - } - - @Override public PsiReference getReference() { - return this; - } - - @Override public String getName() { - SmaliMemberName memberName = getMemberName(); - if (memberName == null) { - return null; - } - return memberName.getText(); - } - - @Override public PsiElement getElement() { - return this; - } - - @Override public TextRange getRangeInElement() { - return new TextRange(0, getTextLength()); - } - - @NotNull @Override public String getCanonicalText() { - return getText(); - } - - @Nullable @Override public PsiField resolve() { - PsiClass containingClass = getContainingClass(); - if (containingClass == null) { - return null; - } - - SmaliMemberName memberName = getMemberName(); - if (memberName == null) { - return null; - } - - return containingClass.findFieldByName(memberName.getText(), true); - } - - @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 PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { - //TODO: implement this - throw new IncorrectOperationException(); - } - - @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { - SmaliMemberName memberName = getMemberName(); - if (memberName == null) { - throw new IncorrectOperationException(); - } - memberName.setName(newElementName); - return this; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFile.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFile.java deleted file mode 100644 index 6ec3bd5f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliFile.java +++ /dev/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.extapi.psi.PsiFileBase; -import com.intellij.psi.FileViewProvider; -import com.intellij.psi.PsiClassOwner; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.SmaliFileType; -import org.jf.smalidea.SmaliLanguage; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliFile extends PsiFileBase implements PsiClassOwner { - public SmaliFile(FileViewProvider viewProvider) { - super(viewProvider, SmaliLanguage.INSTANCE); - } - - @NotNull @Override public SmaliFileType getFileType() { - return SmaliFileType.INSTANCE; - } - - @Nullable - public SmaliClass getPsiClass() { - StubElement stub = (StubElement)getStub(); - if (stub != null) { - StubElement classElement = stub.findChildStubByType(SmaliElementTypes.CLASS); - if (classElement != null) { - return classElement.getPsi(); - } else { - return null; - } - } else { - return findChildByClass(SmaliClass.class); - } - } - - @NotNull @Override public SmaliClass[] getClasses() { - SmaliClass smaliClass = getPsiClass(); - if (smaliClass == null) { - return new SmaliClass[] {}; - } else { - return new SmaliClass[] { smaliClass }; - } - } - - @NotNull @Override public String getPackageName() { - SmaliClass smaliClass = getPsiClass(); - if (smaliClass == null) { - return ""; - } - return smaliClass.getPackageName(); - } - - @Override public void setPackageName(String packageName) throws IncorrectOperationException { - SmaliClass smaliClass = getPsiClass(); - if (smaliClass == null) { - return; - } - smaliClass.setPackageName(packageName); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsList.java deleted file mode 100644 index fb4a788f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsList.java +++ /dev/null @@ -1,81 +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.google.common.collect.Lists; -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.stub.SmaliImplementsListStub; - -import java.util.List; - -public class SmaliImplementsList extends SmaliBaseReferenceList { - public SmaliImplementsList(@NotNull SmaliImplementsListStub stub) { - super(stub, SmaliElementTypes.IMPLEMENTS_LIST); - } - - public SmaliImplementsList(@NotNull ASTNode node) { - super(node); - } - - @NotNull @Override public SmaliClassTypeElement[] getReferenceElements() { - if (!((SmaliClass)getParent()).isInterface()) { - return getImplementsElements(); - } - return new SmaliClassTypeElement[0]; - } - - @NotNull private SmaliClassTypeElement[] getImplementsElements() { - SmaliClass smaliClass = (SmaliClass)getParentByStub(); - assert smaliClass != null; - - SmaliImplementsStatement[] implementsStatements = smaliClass.getImplementsStatements(); - if (implementsStatements.length > 0) { - // all implemented interfaces go in the extends list for an interface - List types = Lists.newArrayList(); - - for (SmaliImplementsStatement implementsStatement: implementsStatements) { - SmaliClassTypeElement classReference = implementsStatement.getClassReference(); - if (classReference != null) { - types.add(classReference); - } - } - return types.toArray(new SmaliClassTypeElement[types.size()]); - } - return new SmaliClassTypeElement[0]; - } - - @Override public Role getRole() { - return Role.IMPLEMENTS_LIST; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsStatement.java deleted file mode 100644 index e50d8c6b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliImplementsStatement.java +++ /dev/null @@ -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 org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliImplementsStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliImplementsStatement(); - } - }; - - public SmaliImplementsStatement() { - super(SmaliElementTypes.IMPLEMENTS_STATEMENT); - } - - @Nullable - public SmaliClassTypeElement getClassReference() { - return findChildByClass(SmaliClassTypeElement.class); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliInstruction.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliInstruction.java deleted file mode 100644 index ecbdbb33..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliInstruction.java +++ /dev/null @@ -1,231 +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.google.common.base.Preconditions; -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.dexlib2.Format; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.Opcodes; -import org.jf.dexlib2.analysis.AnalyzedInstruction; -import org.jf.dexlib2.analysis.MethodAnalyzer; -import org.jf.smalidea.SmaliTokens; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -import java.util.Arrays; -import java.util.List; - -public class SmaliInstruction extends SmaliCompositeElement { - private static final int NO_OFFSET = -1; - - @Nullable private Opcode opcode; - private int offset = NO_OFFSET; - - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliInstruction(); - } - }; - - public SmaliInstruction() { - super(SmaliElementTypes.INSTRUCTION); - } - - @NotNull public SmaliMethod getParentMethod() { - SmaliMethod smaliMethod = findAncestorByClass(SmaliMethod.class); - assert smaliMethod != null; - return smaliMethod; - } - - @NotNull public Opcode getOpcode() { - if (opcode == null) { - ASTNode instructionNode = findChildByType(SmaliTokens.INSTRUCTION_TOKENS); - // this should be impossible, based on the parser definition - assert instructionNode != null; - - // TODO: put a project level Opcodes instance with the appropriate api level somewhere - opcode = Opcodes.getDefault().getOpcodeByName(instructionNode.getText()); - if (opcode == null) { - if (instructionNode.getText().equals(".packed-switch")) { - return Opcode.PACKED_SWITCH_PAYLOAD; - } - if (instructionNode.getText().equals(".sparse-switch")) { - return Opcode.SPARSE_SWITCH_PAYLOAD; - } - if (instructionNode.getText().equals(".array-data")) { - return Opcode.ARRAY_PAYLOAD; - } - assert false; - } - } - return opcode; - } - - public int getOffset() { - // TODO: don't calculate this recursively. ugh! - if (offset == NO_OFFSET) { - SmaliInstruction previousInstruction = findPrevSiblingByClass(SmaliInstruction.class); - if (previousInstruction == null) { - offset = 0; - } else { - offset = previousInstruction.getOffset() + previousInstruction.getInstructionSize(); - } - } - return offset; - } - - public int getRegister(int registerIndex) { - Preconditions.checkArgument(registerIndex >= 0); - - List registers = findChildrenByType(SmaliElementTypes.REGISTER_REFERENCE); - if (registerIndex >= registers.size()) { - return -1; - } - - SmaliRegisterReference registerReference = (SmaliRegisterReference)registers.get(registerIndex); - return registerReference.getRegisterNumber(); - } - - @Nullable - public SmaliLabelReference getTarget() { - return findChildByClass(SmaliLabelReference.class); - } - - public int getRegisterCount() { - return findChildrenByType(SmaliElementTypes.REGISTER_REFERENCE).size(); - } - - @Nullable - public SmaliLiteral getLiteral() { - return findChildByClass(SmaliLiteral.class); - } - - @Nullable - public SmaliTypeElement getTypeReference() { - return findChildByClass(SmaliTypeElement.class); - } - - @Nullable - public SmaliFieldReference getFieldReference() { - return findChildByClass(SmaliFieldReference.class); - } - - @Nullable - public SmaliMethodReference getMethodReference() { - return findChildByClass(SmaliMethodReference.class); - } - - @Nullable - public SmaliLiteral getPackedSwitchStartKey() { - return findChildByClass(SmaliLiteral.class); - } - - @NotNull - public List getPackedSwitchElements() { - return Arrays.asList(findChildrenByClass(SmaliPackedSwitchElement.class)); - } - - @NotNull - public List getSparseSwitchElements() { - return Arrays.asList(findChildrenByClass(SmaliSparseSwitchElement.class)); - } - - @Nullable - public SmaliLiteral getArrayDataWidth() { - return findChildByClass(SmaliLiteral.class); - } - - @NotNull - public List getArrayDataElements() { - return Arrays.asList(findChildrenByClass(SmaliArrayDataElement.class)); - } - - public int getInstructionSize() { - Opcode opcode = getOpcode(); - if (!opcode.format.isPayloadFormat) { - return opcode.format.size; - } else if (opcode.format == Format.ArrayPayload) { - int elementWidth = (int)getArrayDataWidth().getIntegralValue(); - int elementCount = getArrayDataElements().size(); - - return 8 + (elementWidth * elementCount + 1); - } else if (opcode.format == Format.PackedSwitchPayload) { - return 8 + getPackedSwitchElements().size() * 4; - } else if (opcode.format == Format.SparseSwitchPayload) { - return 2 + getSparseSwitchElements().size() * 4; - } - assert false; - throw new RuntimeException(); - } - - private AnalyzedInstruction analyzedInstruction = null; - - @Nullable - private AnalyzedInstruction getAnalyzedInstructionFromMethod() { - SmaliMethod method = getParentMethod(); - - MethodAnalyzer analyzer = method.getMethodAnalyzer(); - if (analyzer == null) { - return null; - } - - int thisOffset = this.getOffset() / 2; - int codeOffset = 0; - - for (AnalyzedInstruction instruction: analyzer.getAnalyzedInstructions()) { - if (codeOffset == thisOffset) { - return instruction; - } - assert codeOffset < thisOffset; - - codeOffset += instruction.getOriginalInstruction().getCodeUnits(); - } - assert false; - return null; - } - - @Nullable - public AnalyzedInstruction getAnalyzedInstruction() { - if (analyzedInstruction == null) { - analyzedInstruction = getAnalyzedInstructionFromMethod(); - } - return analyzedInstruction; - } - - @Override public void clearCaches() { - super.clearCaches(); - analyzedInstruction = null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabel.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabel.java deleted file mode 100644 index b07220dd..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabel.java +++ /dev/null @@ -1,75 +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 SmaliLabel extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLabel(); - } - }; - - public SmaliLabel() { - super(SmaliElementTypes.LABEL); - } - - @Override public String getName() { - return getText().substring(1); - } - - @Nullable - public SmaliInstruction getInstruction() { - return findNextSiblingByClass(SmaliInstruction.class); - } - - @Nullable - private SmaliInstruction getPreviousInstruction() { - return findPrevSiblingByClass(SmaliInstruction.class); - } - - public int getOffset() { - SmaliInstruction instruction = getInstruction(); - if (instruction == null) { - instruction = getPreviousInstruction(); - if (instruction == null) { - return 0; - } - // TODO: handle variable size instructions - return instruction.getOffset() + instruction.getOpcode().format.size; - } - return instruction.getOffset(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabelReference.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabelReference.java deleted file mode 100644 index 940f4296..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLabelReference.java +++ /dev/null @@ -1,104 +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.PsiElement; -import com.intellij.psi.PsiReference; -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 SmaliLabelReference extends SmaliCompositeElement implements PsiReference { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLabelReference(); - } - }; - - public SmaliLabelReference() { - super(SmaliElementTypes.LABEL_REFERENCE); - } - - @Override public String getName() { - return getText().substring(1); - } - - @Override public PsiReference getReference() { - return this; - } - - @Override public PsiElement getElement() { - return this; - } - - @Override public TextRange getRangeInElement() { - return new TextRange(0, getTextLength()); - } - - @Nullable @Override public SmaliLabel resolve() { - SmaliMethod method = findAncestorByClass(SmaliMethod.class); - if (method == null) { - return null; - } - return method.getLabel(getText()); - } - - @NotNull @Override public String getCanonicalText() { - return getText(); - } - - @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 PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { - //TODO: implement this - throw new IncorrectOperationException(); - } - - @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { - //TODO: implement this - throw new IncorrectOperationException(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLineDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLineDebugStatement.java deleted file mode 100644 index 7ea3227b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLineDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliLineDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLineDebugStatement(); - } - }; - - public SmaliLineDebugStatement() { - super(SmaliElementTypes.LINE_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLiteral.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLiteral.java deleted file mode 100644 index 0a9f5382..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLiteral.java +++ /dev/null @@ -1,75 +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.tree.IElementType; -import org.jf.smali.LiteralTools; -import org.jf.smalidea.SmaliTokens; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliLiteral extends SmaliCompositeElement implements PsiAnnotationMemberValue { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLiteral(); - } - }; - - public SmaliLiteral() { - super(SmaliElementTypes.LITERAL); - } - - public long getIntegralValue() { - ASTNode literalNode = getNode().getFirstChildNode(); - IElementType literalType = literalNode.getElementType(); - - if (literalType == SmaliTokens.LONG_LITERAL) { - return LiteralTools.parseLong(literalNode.getText()); - } else if (literalType == SmaliTokens.NEGATIVE_INTEGER_LITERAL || - literalType == SmaliTokens.POSITIVE_INTEGER_LITERAL) { - return LiteralTools.parseInt(literalNode.getText()); - } else if (literalType == SmaliTokens.SHORT_LITERAL) { - return LiteralTools.parseShort(literalNode.getText()); - } else if (literalType == SmaliTokens.CHAR_LITERAL) { - // TODO: implement this - return -1; - } else if (literalType == SmaliTokens.BYTE_LITERAL) { - return LiteralTools.parseByte(literalNode.getText()); - } else if (literalType == SmaliTokens.BOOL_LITERAL) { - return Boolean.parseBoolean(literalNode.getText())?1:0; - } else { - throw new RuntimeException("Not an integral literal"); - } - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalDebugStatement.java deleted file mode 100644 index 02d1748c..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliLocalDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLocalDebugStatement(); - } - }; - - public SmaliLocalDebugStatement() { - super(SmaliElementTypes.LOCAL_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalName.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalName.java deleted file mode 100644 index 6ade23a4..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliLocalName.java +++ /dev/null @@ -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.PsiIdentifier; -import com.intellij.psi.tree.IElementType; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliLocalName extends SmaliCompositeElement implements PsiIdentifier { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliLocalName(); - } - }; - - public SmaliLocalName() { - super(SmaliElementTypes.LOCAL_NAME); - } - - @Override public IElementType getTokenType() { - return getNode().getElementType(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMemberName.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMemberName.java deleted file mode 100644 index f3377366..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMemberName.java +++ /dev/null @@ -1,69 +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.PsiIdentifier; -import com.intellij.psi.impl.source.codeStyle.CodeEditUtil; -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.leaf.SmaliSimpleName; - -public class SmaliMemberName extends SmaliCompositeElement implements PsiIdentifier { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliMemberName(); - } - }; - - public SmaliMemberName() { - super(SmaliElementTypes.MEMBER_NAME); - } - - @Override public IElementType getTokenType() { - return getElementType(); - } - - @Override - public String getName() { - return this.getText(); - } - - public void setName(@NotNull String newElementName) { - removeAllChildren(); - SmaliSimpleName newNameElement = new SmaliSimpleName(newElementName); - CodeEditUtil.setNodeGenerated(newNameElement, true); - - addChild(newNameElement); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java deleted file mode 100644 index 8ba618b3..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethod.java +++ /dev/null @@ -1,371 +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.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.Maps; -import com.intellij.debugger.SourcePosition; -import com.intellij.lang.ASTNode; -import com.intellij.openapi.editor.Document; -import com.intellij.psi.*; -import com.intellij.psi.PsiModifier.ModifierConstant; -import com.intellij.psi.impl.PsiImplUtil; -import com.intellij.psi.impl.PsiSuperMethodImplUtil; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.util.MethodSignature; -import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.dexlib2.analysis.AnalysisException; -import org.jf.dexlib2.analysis.ClassPath; -import org.jf.dexlib2.analysis.MethodAnalyzer; -import org.jf.smalidea.dexlib.SmalideaMethod; -import org.jf.smalidea.dexlib.analysis.SmalideaClassProvider; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.iface.SmaliModifierListOwner; -import org.jf.smalidea.psi.stub.SmaliMethodStub; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class SmaliMethod extends SmaliStubBasedPsiElement - implements PsiMethod, SmaliModifierListOwner, PsiAnnotationMethod { - public SmaliMethod(@NotNull SmaliMethodStub stub) { - super(stub, SmaliElementTypes.METHOD); - } - - public SmaliMethod(@NotNull ASTNode node) { - super(node); - } - - @NotNull @Override public String getName() { - SmaliMethodStub stub = getStub(); - String name = null; - if (stub != null) { - name = stub.getName(); - } else { - SmaliMemberName nameIdentifier = getNameIdentifier(); - if (nameIdentifier != null) { - name = nameIdentifier.getText(); - } - } - if (name == null || name.isEmpty()) { - name = ""; - } - return name; - } - - @Override public boolean hasTypeParameters() { - // TODO: (generics) implement this - return false; - } - - @NotNull - public SmaliMethodPrototype getMethodPrototype() { - return getRequiredStubOrPsiChild(SmaliElementTypes.METHOD_PROTOTYPE); - } - - @Nullable @Override public PsiType getReturnType() { - if (isConstructor()) return null; - return getMethodPrototype().getReturnType(); - } - - @Nullable @Override public PsiTypeElement getReturnTypeElement() { - if (isConstructor()) return null; - return getMethodPrototype().getReturnTypeElement(); - } - - @NotNull @Override public SmaliMethodParamList getParameterList() { - return getMethodPrototype().getParameterList(); - } - - @NotNull @Override public SmaliThrowsList getThrowsList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.THROWS_LIST); - } - - @Nullable @Override public PsiCodeBlock getBody() { - // not applicable - return null; - } - - @NotNull public List getInstructions() { - return findChildrenByType(SmaliElementTypes.INSTRUCTION); - } - - @NotNull public List getCatchStatements() { - return Arrays.asList(findChildrenByClass(SmaliCatchStatement.class)); - } - - @Nullable public SourcePosition getSourcePositionForCodeOffset(int offset) { - for (SmaliInstruction instruction: getInstructions()) { - if (instruction.getOffset() >= offset) { - return SourcePosition.createFromElement(instruction); - } - } - return null; - } - - public int getOffsetForLine(int line) { - PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject()); - final Document document = documentManager.getDocument(getContainingFile()); - if (document == null) { - return -1; - } - - for (final SmaliInstruction instruction: getInstructions()) { - int curLine = document.getLineNumber(instruction.getTextOffset()); - if (curLine >= line) { - return instruction.getOffset(); - } - } - return -1; - } - - public int getRegisterCount() { - SmaliRegistersStatement registersStatement = findChildByClass(SmaliRegistersStatement.class); - if (registersStatement == null) { - return 0; - } - return registersStatement.getRegisterCount(); - } - - public int getParameterRegisterCount() { - int parameterRegisterCount = getMethodPrototype().getParameterList().getParameterRegisterCount(); - if (!isStatic()) { - parameterRegisterCount++; - } - return parameterRegisterCount; - } - - @NotNull public SmaliParameterStatement[] getParameterStatements() { - return findChildrenByClass(SmaliParameterStatement.class); - } - - @Override public boolean isConstructor() { - // TODO: should this return true for the class initializer? - return hasModifierProperty("constructor") && !hasModifierProperty("static"); - } - - public boolean isStatic() { - return hasModifierProperty("static"); - } - - @Override public boolean isVarArgs() { - return hasModifierProperty("varargs"); - } - - @NotNull @Override public MethodSignature getSignature(@NotNull PsiSubstitutor substitutor) { - return MethodSignatureBackedByPsiMethod.create(this, substitutor); - } - - @Nullable @Override public SmaliMemberName getNameIdentifier() { - return findChildByClass(SmaliMemberName.class); - } - - @NotNull @Override public PsiMethod[] findSuperMethods() { - return PsiSuperMethodImplUtil.findSuperMethods(this); - } - - @NotNull @Override public PsiMethod[] findSuperMethods(boolean checkAccess) { - return PsiSuperMethodImplUtil.findSuperMethods(this, checkAccess); - } - - @NotNull @Override public PsiMethod[] findSuperMethods(PsiClass parentClass) { - return PsiSuperMethodImplUtil.findSuperMethods(this, parentClass); - } - - @NotNull @Override - public List findSuperMethodSignaturesIncludingStatic(boolean checkAccess) { - return PsiSuperMethodImplUtil.findSuperMethodSignaturesIncludingStatic(this, checkAccess); - } - - @Nullable @Override public PsiMethod findDeepestSuperMethod() { - return PsiSuperMethodImplUtil.findDeepestSuperMethod(this); - } - - @NotNull @Override public PsiMethod[] findDeepestSuperMethods() { - return PsiSuperMethodImplUtil.findDeepestSuperMethods(this); - } - - @NotNull @Override public SmaliModifierList getModifierList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.MODIFIER_LIST); - } - - @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - SmaliMemberName smaliMemberName = getNameIdentifier(); - if (smaliMemberName == null) { - throw new IncorrectOperationException(); - } - smaliMemberName.setName(name); - return this; - } - - @NotNull @Override public HierarchicalMethodSignature getHierarchicalMethodSignature() { - return PsiSuperMethodImplUtil.getHierarchicalMethodSignature(this); - } - - @Nullable @Override public PsiDocComment getDocComment() { - // not applicable - return null; - } - - @Override public boolean isDeprecated() { - return PsiImplUtil.isDeprecatedByAnnotation(this); - } - - @Nullable @Override public PsiTypeParameterList getTypeParameterList() { - // TODO: (generics) implement this - return null; - } - - @NotNull @Override public PsiTypeParameter[] getTypeParameters() { - // TODO: (generics) implement this - return new PsiTypeParameter[0]; - } - - @Nullable @Override public SmaliClass getContainingClass() { - PsiElement parent = getParentByStub(); - if (parent instanceof SmaliClass) { - return (SmaliClass) parent; - } - return null; - } - - @Override public boolean hasModifierProperty(@ModifierConstant @NonNls @NotNull String name) { - return getModifierList().hasModifierProperty(name); - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - return getStubOrPsiChildren(SmaliElementTypes.ANNOTATION, new SmaliAnnotation[0]); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - for (SmaliAnnotation annotation: getAnnotations()) { - if (qualifiedName.equals(annotation.getQualifiedName())) { - return annotation; - } - } - return null; - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - // TODO: implement this - return null; - } - - private final Supplier> labelMap = Suppliers.memoize( - new Supplier>() { - @Override public Map get() { - Map labelMap = Maps.newHashMap(); - for (SmaliLabel label: findChildrenByClass(SmaliLabel.class)) { - if (!labelMap.containsKey(label.getText())) { - labelMap.put(label.getText(), label); - } - } - return labelMap; - } - }); - - @Nullable public SmaliLabel getLabel(String name) { - return labelMap.get().get(name); - } - - private MethodAnalyzer methodAnalyzer = null; - - @Nullable - public MethodAnalyzer getMethodAnalyzer() { - if (methodAnalyzer == null) { - if (!PsiTreeUtil.hasErrorElements(this)) { - ClassPath classPath; - try { - classPath = new ClassPath( - new SmalideaClassProvider(getProject(), getContainingFile().getVirtualFile())); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - - try { - methodAnalyzer = new MethodAnalyzer(classPath, new SmalideaMethod(SmaliMethod.this), null, false); - } catch (AnalysisException ex) { - methodAnalyzer = null; - } - } - } - return methodAnalyzer; - } - - @Override public void subtreeChanged() { - super.subtreeChanged(); - methodAnalyzer = null; - } - - @Override public int getTextOffset() { - SmaliMemberName smaliMemberName = getNameIdentifier(); - if (smaliMemberName != null) { - return smaliMemberName.getTextOffset(); - } - return super.getTextOffset(); - } - - @Nullable @Override public PsiAnnotationMemberValue getDefaultValue() { - SmaliClass containingClass = getContainingClass(); - if (containingClass == null || !containingClass.isAnnotationType()) { - return null; - } - - for (SmaliAnnotation annotation: containingClass.getAnnotations()) { - String annotationType = annotation.getQualifiedName(); - if (annotationType == null) { - continue; - } - if (annotationType.equals("dalvik.annotation.AnnotationDefault")) { - PsiAnnotationMemberValue value = annotation.findAttributeValue("value"); - if (!(value instanceof SmaliAnnotation)) { - return null; - } - SmaliAnnotation valueSubAnnotation = (SmaliAnnotation)value; - return valueSubAnnotation.findAttributeValue(getName()); - } - } - return null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParamList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParamList.java deleted file mode 100644 index 0b759f02..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParamList.java +++ /dev/null @@ -1,80 +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.PsiParameter; -import com.intellij.psi.PsiParameterList; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.stub.SmaliMethodParamListStub; - -import java.util.Arrays; - -public class SmaliMethodParamList extends SmaliStubBasedPsiElement - implements PsiParameterList { - public SmaliMethodParamList(@NotNull SmaliMethodParamListStub stub) { - super(stub, SmaliElementTypes.METHOD_PARAM_LIST); - } - - public SmaliMethodParamList(@NotNull ASTNode node) { - super(node); - } - - @NotNull @Override public SmaliMethodParameter[] getParameters() { - return getStubOrPsiChildren(SmaliElementTypes.METHOD_PARAMETER, new SmaliMethodParameter[0]); - } - - @Override public int getParameterIndex(PsiParameter parameter) { - if (!(parameter instanceof SmaliMethodParameter)) { - return -1; - } - return Arrays.asList(getParameters()).indexOf(parameter); - } - - @Override public int getParametersCount() { - return getParameters().length; - } - - /** - * Returns the number of registers needed for the parameters in this parameter list - * - * Note: this does *not* include the implicit "this" parameter, if applicable - */ - public int getParameterRegisterCount() { - int count = 0; - for (SmaliMethodParameter param: getParameters()) { - count += param.getRegisterCount(); - } - return count; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParameter.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParameter.java deleted file mode 100644 index 93d376e8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodParameter.java +++ /dev/null @@ -1,223 +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.PsiModifier.ModifierConstant; -import com.intellij.util.IncorrectOperationException; -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.iface.SmaliModifierListOwner; -import org.jf.smalidea.psi.stub.SmaliMethodParameterStub; -import org.jf.smalidea.util.NameUtils; - -public class SmaliMethodParameter extends SmaliStubBasedPsiElement - implements PsiParameter, SmaliModifierListOwner { - public SmaliMethodParameter(@NotNull SmaliMethodParameterStub stub) { - super(stub, SmaliElementTypes.METHOD_PARAMETER); - } - - public SmaliMethodParameter(@NotNull ASTNode node) { - super(node); - } - - @NotNull @Override public SmaliModifierList getModifierList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.MODIFIER_LIST); - } - - @NotNull @Override public PsiElement getDeclarationScope() { - return getParentMethod(); - } - - @Override public boolean isVarArgs() { - if (getType().getArrayDimensions() == 0 || !getParentMethod().isVarArgs()) { - return false; - } - - SmaliMethodParamList paramList = getStubOrPsiParentOfType(SmaliMethodParamList.class); - if (paramList == null) { - return false; - } - SmaliMethodParameter[] parameters = paramList.getParameters(); - // is this the last parameter? - return parameters[parameters.length-1] == this; - } - - @NotNull @Override public SmaliTypeElement getTypeElement() { - SmaliTypeElement typeElement = findChildByClass(SmaliTypeElement.class); - assert typeElement != null; - return typeElement; - } - - @NotNull @Override public PsiType getType() { - SmaliMethodParameterStub stub = getStub(); - if (stub != null) { - return NameUtils.resolveSmaliToPsiType(this, stub.getSmaliTypeName()); - } - return getTypeElement().getType(); - } - - @Nullable @Override public PsiExpression getInitializer() { - // not applicable - return null; - } - - @Override public boolean hasInitializer() { - return false; - } - - @Override public void normalizeDeclaration() throws IncorrectOperationException { - // not applicable - } - - @Nullable @Override public Object computeConstantValue() { - // not applicable - return null; - } - - @Nullable @Override public String getName() { - SmaliMethodParameterStub stub = getStub(); - if (stub != null) { - return stub.getName(); - } - SmaliLocalName name = getNameIdentifier(); - if (name == null) { - return null; - } - // TODO: get the actual string value - return getNameIdentifier().getText(); - } - - @Nullable @Override public SmaliLocalName getNameIdentifier() { - SmaliParameterStatement parameterStatement = findParameterStatement(); - if (parameterStatement == null) { - return null; - } - - return parameterStatement.getNameIdentifier(); - } - - @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - // TODO: implement this - throw new UnsupportedOperationException(); - } - - @Override public boolean hasModifierProperty(@ModifierConstant @NonNls @NotNull String name) { - // not applicable - return false; - } - - /** - * Returns the number of registers required for this parameter. 1 for most types, but 2 for double/long. - */ - public int getRegisterCount() { - PsiType type = getType(); - if (type == PsiType.DOUBLE || type == PsiType.LONG) { - return 2; - } - return 1; - } - - @NotNull public SmaliMethod getParentMethod() { - SmaliMethod smaliMethod = findStubOrPsiAncestorOfType(SmaliMethod.class); - assert smaliMethod != null; - return smaliMethod; - } - - /** - * Gets the parameter register number of this parameters. This is the number of a pNN style register reference. - */ - public int getParameterRegisterNumber() { - // TODO: it might be a good idea to cache this, or at least do it non-recursively - PsiElement prevSibling = getPrevSibling(); - if (prevSibling == null) { - return getParentMethod().isStatic() ? 0 : 1; - } - assert prevSibling instanceof SmaliMethodParameter; - SmaliMethodParameter prevParam = (SmaliMethodParameter)prevSibling; - return prevParam.getParameterRegisterNumber() + prevParam.getRegisterCount(); - } - - /** - * Gets the register number of this parameters. This is the number of a rNN style register reference. - */ - public int getRegisterNumber() { - SmaliMethod parentMethod = getParentMethod(); - return getParameterRegisterNumber() + parentMethod.getRegisterCount() - - parentMethod.getParameterRegisterCount(); - } - - @Nullable - private SmaliParameterStatement findParameterStatement() { - SmaliMethod parentMethod = getParentMethod(); - - for (SmaliParameterStatement parameterStatement: parentMethod.getParameterStatements()) { - SmaliRegisterReference registerReference = parameterStatement.getParameterRegister(); - if (registerReference != null && registerReference.getRegisterNumber() == getRegisterNumber()) { - return parameterStatement; - } - } - return null; - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - SmaliParameterStatement parameterStatement = findParameterStatement(); - if (parameterStatement == null) { - return new SmaliAnnotation[0]; - } - return parameterStatement.getAnnotations(); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - SmaliParameterStatement parameterStatement = findParameterStatement(); - if (parameterStatement == null) { - return null; - } - return parameterStatement.findAnnotation(qualifiedName); - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - SmaliParameterStatement parameterStatement = findParameterStatement(); - if (parameterStatement == null) { - // TODO: add a parameter statement for this parameter if not found - throw new UnsupportedOperationException(); - } - return parameterStatement.addAnnotation(qualifiedName); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java deleted file mode 100644 index 3b2aae3b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodPrototype.java +++ /dev/null @@ -1,77 +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 org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.stub.SmaliMethodPrototypeStub; -import org.jf.smalidea.util.NameUtils; - -public class SmaliMethodPrototype extends SmaliStubBasedPsiElement { - public SmaliMethodPrototype(@NotNull SmaliMethodPrototypeStub stub) { - super(stub, SmaliElementTypes.METHOD_PROTOTYPE); - } - - public SmaliMethodPrototype(@NotNull ASTNode node) { - super(node); - } - - @Nullable - public PsiType getReturnType() { - SmaliMethodPrototypeStub stub = getStub(); - if (stub != null) { - String returnSmaliTypeName = stub.getReturnSmaliTypeName(); - if (returnSmaliTypeName == null) { - return null; - } - return NameUtils.resolveSmaliToPsiType(this, returnSmaliTypeName); - } - - PsiTypeElement returnTypeElement = getReturnTypeElement(); - if (returnTypeElement == null) { - return null; - } - return returnTypeElement.getType(); - } - - @Nullable public SmaliTypeElement getReturnTypeElement() { - return findChildByClass(SmaliTypeElement.class); - } - - @NotNull - public SmaliMethodParamList getParameterList() { - return getRequiredStubOrPsiChild(SmaliElementTypes.METHOD_PARAM_LIST); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReference.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReference.java deleted file mode 100644 index f8048e9f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReference.java +++ /dev/null @@ -1,192 +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.google.common.collect.Lists; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.PsiType; -import com.intellij.psi.impl.light.LightMethodBuilder; -import com.intellij.util.ArrayUtil; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.SmaliLanguage; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; - -public class SmaliMethodReference extends SmaliCompositeElement implements PsiReference { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliMethodReference(); - } - }; - - @Override public String getName() { - PsiElement memberName = getMemberName(); - if (memberName == null) { - return null; - } - return memberName.getText(); - } - - public SmaliMethodReference() { - super(SmaliElementTypes.METHOD_REFERENCE); - } - - @Override public PsiReference getReference() { - return this; - } - - @Override public PsiElement getElement() { - return this; - } - - @Override public TextRange getRangeInElement() { - return new TextRange(0, getTextLength()); - } - - @Nullable - public PsiClass getContainingClass() { - SmaliClassTypeElement containingClassReference = getContainingType(); - if (containingClassReference == null) { - return null; - } - PsiClass containingClass = containingClassReference.resolve(); - if (containingClass == null) { - return null; - } - - return containingClass; - } - - @Nullable - public SmaliClassTypeElement getContainingType() { - return findChildByClass(SmaliClassTypeElement.class); - } - - @Nullable - public SmaliMemberName getMemberName() { - return findChildByClass(SmaliMemberName.class); - } - - @Nonnull - public List getParameterTypes() { - SmaliMethodReferenceParamList paramList = findChildByClass(SmaliMethodReferenceParamList.class); - if (paramList == null) { - return Lists.newArrayList(); - } - - SmaliTypeElement[] parameterElements = paramList.getParameterTypes(); - - List types = new ArrayList(parameterElements.length); - for (SmaliTypeElement parameterElement: parameterElements) { - types.add(parameterElement.getType()); - } - return types; - } - - @Nullable - public SmaliTypeElement getReturnType() { - SmaliTypeElement[] types = findChildrenByClass(SmaliTypeElement.class); - if (types.length < 2) { - return null; - } - return types[1]; - } - - @Nullable @Override public PsiElement resolve() { - PsiClass containingClass = getContainingClass(); - if (containingClass == null) { - return null; - } - - SmaliMemberName memberName = getMemberName(); - if (memberName == null) { - return null; - } - - LightMethodBuilder pattern = new LightMethodBuilder(getManager(), SmaliLanguage.INSTANCE, memberName.getText()); - - for (PsiType type: getParameterTypes()) { - pattern.addParameter("", type); - } - - SmaliTypeElement returnTypeElement = getReturnType(); - if (returnTypeElement == null) { - return null; - } - - pattern.setMethodReturnType(returnTypeElement.getType()); - - // TODO: what about static constructor? - pattern.setConstructor(memberName.getText().equals("")); - - return containingClass.findMethodBySignature(pattern, true); - } - - @NotNull @Override public String getCanonicalText() { - return getText(); - } - - @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 PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { - SmaliMemberName memberName = getMemberName(); - if (memberName == null) { - throw new IncorrectOperationException(); - } - memberName.setName(newElementName); - return this; - } - - @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { - //TODO: implement this - throw new IncorrectOperationException(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReferenceParamList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReferenceParamList.java deleted file mode 100644 index f9dccf06..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliMethodReferenceParamList.java +++ /dev/null @@ -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.NotNull; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliMethodReferenceParamList extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliMethodReferenceParamList(); - } - }; - - public SmaliMethodReferenceParamList() { - super(SmaliElementTypes.METHOD_REFERENCE_PARAM_LIST); - } - - @NotNull public SmaliTypeElement[] getParameterTypes() { - return findChildrenByClass(SmaliTypeElement.class); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliModifierList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliModifierList.java deleted file mode 100644 index c23763fc..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliModifierList.java +++ /dev/null @@ -1,166 +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.openapi.command.WriteCommandAction; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiModifier.ModifierConstant; -import com.intellij.psi.PsiModifierList; -import com.intellij.psi.PsiModifierListOwner; -import com.intellij.psi.StubBasedPsiElement; -import com.intellij.psi.impl.source.tree.Factory; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.dexlib2.AccessFlags; -import org.jf.smalidea.SmaliTokens; -import org.jf.smalidea.psi.iface.SmaliModifierListOwner; -import org.jf.smalidea.psi.stub.SmaliModifierListStub; -import org.jf.smalidea.psi.stub.element.SmaliModifierListElementType; - -import javax.annotation.Nonnull; - -public class SmaliModifierList extends SmaliStubBasedPsiElement - implements StubBasedPsiElement, PsiModifierList { - public SmaliModifierList(@NotNull ASTNode node) { - super(node); - } - - public SmaliModifierList(@NotNull SmaliModifierListStub stub) { - super(stub, SmaliModifierListElementType.INSTANCE); - } - - public int getAccessFlags() { - SmaliModifierListStub stub = getStub(); - if (stub != null) { - return stub.getAccessFlags(); - } - - int flags = 0; - - for (PsiElement accessSpec: findChildrenByType(SmaliTokens.ACCESS_SPEC)) { - AccessFlags flag = AccessFlags.getAccessFlag(accessSpec.getText()); - if (flag != null) { - flags |= flag.getValue(); - } - } - - return flags; - } - - @Override public boolean hasModifierProperty(@ModifierConstant @NotNull @NonNls String name) { - return hasExplicitModifier(name); - } - - @Override public boolean hasExplicitModifier(@ModifierConstant @NotNull @NonNls String name) { - SmaliModifierListStub stub = getStub(); - if (stub != null) { - AccessFlags flag = AccessFlags.getAccessFlag(name); - if (flag == null) { - return false; - } - return (stub.getAccessFlags() & flag.getValue()) != 0; - } - - for (PsiElement accessSpec: findChildrenByType(SmaliTokens.ACCESS_SPEC)) { - if (accessSpec.getText().equals(name)) { - return true; - } - } - - return false; - } - - @Override - public void setModifierProperty(@ModifierConstant @NotNull @NonNls String name, boolean addModifier) - throws IncorrectOperationException { - if (addModifier) { - - final TreeElement leaf = Factory.createSingleLeafElement(SmaliTokens.ACCESS_SPEC, name, null, getManager()); - - new WriteCommandAction.Simple(getProject(), getContainingFile()) { - @Override protected void run() throws Throwable { - addInternal(leaf, leaf, null, null); - } - }.execute(); - } else { - final PsiElement accessSpec = getAccessFlagElement(name); - if (accessSpec != null) { - new WriteCommandAction.Simple(getProject(), getContainingFile()) { - @Override protected void run() throws Throwable { - accessSpec.delete(); - } - }.execute(); - } - } - } - - @Override - public void checkSetModifierProperty(@ModifierConstant @NotNull @NonNls String name, boolean addModifier) - throws IncorrectOperationException { - } - - @Nonnull - private SmaliModifierListOwner getParentForAnnotations() { - SmaliModifierListOwner parent = (SmaliModifierListOwner)getStubOrPsiParentOfType(PsiModifierListOwner.class); - assert parent != null; - return parent; - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - return getParentForAnnotations().getAnnotations(); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getParentForAnnotations().getApplicableAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - return getParentForAnnotations().findAnnotation(qualifiedName); - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - return getParentForAnnotations().addAnnotation(qualifiedName); - } - - @Nullable public PsiElement getAccessFlagElement(@NotNull String accessFlag) { - for (PsiElement accessSpec: findChildrenByType(SmaliTokens.ACCESS_SPEC)) { - if (accessSpec.getText().equals(accessFlag)) { - return accessSpec; - } - } - return null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPackedSwitchElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPackedSwitchElement.java deleted file mode 100644 index b0e04150..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPackedSwitchElement.java +++ /dev/null @@ -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 SmaliPackedSwitchElement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliPackedSwitchElement(); - } - }; - - public SmaliPackedSwitchElement() { - super(SmaliElementTypes.PACKED_SWITCH_ELEMENT); - } - - @Nullable - public SmaliLabelReference getTarget() { - return findChildByClass(SmaliLabelReference.class); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliParameterStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliParameterStatement.java deleted file mode 100644 index 5fa8c4cd..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliParameterStatement.java +++ /dev/null @@ -1,83 +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.PsiAnnotationOwner; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliParameterStatement extends SmaliCompositeElement implements PsiAnnotationOwner { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliParameterStatement(); - } - }; - - public SmaliParameterStatement() { - super(SmaliElementTypes.PARAMETER_STATEMENT); - } - - @Nullable - public SmaliLocalName getNameIdentifier() { - return findChildByClass(SmaliLocalName.class); - } - - @Nullable - public SmaliRegisterReference getParameterRegister() { - return findChildByClass(SmaliRegisterReference.class); - } - - @NotNull @Override public SmaliAnnotation[] getAnnotations() { - return findChildrenByClass(SmaliAnnotation.class); - } - - @NotNull @Override public SmaliAnnotation[] getApplicableAnnotations() { - return getAnnotations(); - } - - @Nullable @Override public SmaliAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { - for (SmaliAnnotation annotation: getAnnotations()) { - if (qualifiedName.equals(annotation.getQualifiedName())) { - return annotation; - } - } - return null; - } - - @NotNull @Override public SmaliAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { - // TODO: implement this - return null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrimitiveTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrimitiveTypeElement.java deleted file mode 100644 index 4bdf65a6..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrimitiveTypeElement.java +++ /dev/null @@ -1,72 +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.PsiType; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliPrimitiveTypeElement extends SmaliTypeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliPrimitiveTypeElement(); - } - }; - - public SmaliPrimitiveTypeElement() { - super(SmaliElementTypes.PRIMITIVE_TYPE); - } - - @NotNull @Override public PsiType getType() { - switch (getText().charAt(0)) { - case 'Z': - return PsiType.BOOLEAN; - case 'B': - return PsiType.BYTE; - case 'S': - return PsiType.SHORT; - case 'C': - return PsiType.CHAR; - case 'I': - return PsiType.INT; - case 'J': - return PsiType.LONG; - case 'F': - return PsiType.FLOAT; - case 'D': - return PsiType.DOUBLE; - default: - throw new RuntimeException("Unexpected primitive type"); - } - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrologueDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrologueDebugStatement.java deleted file mode 100644 index c4f73f0b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliPrologueDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliPrologueDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliPrologueDebugStatement(); - } - }; - - public SmaliPrologueDebugStatement() { - super(SmaliElementTypes.PROLOGUE_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegisterReference.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegisterReference.java deleted file mode 100644 index 3c2fe7b2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegisterReference.java +++ /dev/null @@ -1,70 +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.NotNull; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliRegisterReference extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliRegisterReference(); - } - }; - - public SmaliRegisterReference() { - super(SmaliElementTypes.REGISTER_REFERENCE); - } - - @NotNull - public SmaliMethod getParentMethod() { - SmaliMethod parentMethod = findAncestorByClass(SmaliMethod.class); - assert parentMethod != null; - return parentMethod; - } - - public int getRegisterNumber() { - int registerNumber = Integer.parseInt(getText().substring(1)); - - if (isParameterRegister()) { - SmaliMethod method = getParentMethod(); - registerNumber += method.getRegisterCount() - method.getParameterRegisterCount(); - } - - return registerNumber; - } - - public boolean isParameterRegister() { - return getText().charAt(0) == 'p'; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegistersStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegistersStatement.java deleted file mode 100644 index 93080a70..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRegistersStatement.java +++ /dev/null @@ -1,75 +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.NotNull; -import org.jf.smalidea.SmaliTokens; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliRegistersStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliRegistersStatement(); - } - }; - - public SmaliRegistersStatement() { - super(SmaliElementTypes.REGISTERS_STATEMENT); - } - - @NotNull - private SmaliMethod getParentMethod() { - return findAncestorByClass(SmaliMethod.class); - } - - /** - * Get the total number of registers for the method - */ - public int getRegisterCount() { - SmaliLiteral literal = findChildByClass(SmaliLiteral.class); - assert literal != null; - - long registerCount = literal.getIntegralValue(); - // TODO: check for register count that's too large - if (isLocals()) { - SmaliMethod parentMethod = getParentMethod(); - return (int)registerCount + parentMethod.getParameterRegisterCount(); - } - return (int)registerCount; - } - - private boolean isLocals() { - return findChildByType(SmaliTokens.LOCALS_DIRECTIVE) != null; - } - -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRestartLocalDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRestartLocalDebugStatement.java deleted file mode 100644 index e2736079..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliRestartLocalDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliRestartLocalDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliRestartLocalDebugStatement(); - } - }; - - public SmaliRestartLocalDebugStatement() { - super(SmaliElementTypes.RESTART_LOCAL_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceDebugStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceDebugStatement.java deleted file mode 100644 index 758e175e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceDebugStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliSourceDebugStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliSourceDebugStatement(); - } - }; - - public SmaliSourceDebugStatement() { - super(SmaliElementTypes.SOURCE_DEBUG_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceStatement.java deleted file mode 100644 index 4f696cf2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSourceStatement.java +++ /dev/null @@ -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.psi.impl; - -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliSourceStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliSourceStatement(); - } - }; - - public SmaliSourceStatement() { - super(SmaliElementTypes.SOURCE_STATEMENT); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSparseSwitchElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSparseSwitchElement.java deleted file mode 100644 index 28fee439..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSparseSwitchElement.java +++ /dev/null @@ -1,58 +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 SmaliSparseSwitchElement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliSparseSwitchElement(); - } - }; - - public SmaliSparseSwitchElement() { - super(SmaliElementTypes.SPARSE_SWITCH_ELEMENT); - } - - @Nullable - public SmaliLiteral getKey() { - return findChildByClass(SmaliLiteral.class); - } - - @Nullable - public SmaliLabelReference getTarget() { - return findChildByClass(SmaliLabelReference.class); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliStubBasedPsiElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliStubBasedPsiElement.java deleted file mode 100644 index 5df05e25..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliStubBasedPsiElement.java +++ /dev/null @@ -1,82 +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.extapi.psi.StubBasedPsiElementBase; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public abstract class SmaliStubBasedPsiElement extends StubBasedPsiElementBase - implements StubBasedPsiElement { - protected SmaliStubBasedPsiElement(@NotNull T stub, @NotNull IStubElementType nodeType) { - super(stub, nodeType); - } - - protected SmaliStubBasedPsiElement(@NotNull ASTNode node) { - super(node); - } - - @SuppressWarnings("unchecked") - @Nullable - protected E findStubOrPsiAncestorOfType(@NotNull Class aClass) { - T stub = getStub(); - if (stub != null) { - StubElement parent = stub.getParentStub(); - while (parent != null) { - PsiElement parentPsi = parent.getPsi(); - if (aClass.isInstance(parentPsi)) { - return (E)parentPsi; - } - parent = parent.getParentStub(); - } - return null; - } - - PsiElement parent = getParent(); - while (parent != null) { - if (aClass.isInstance(parent)) { - return (E)parent; - } - parent = parent.getParent(); - } - return null; - } - - public String toString() { - return this.getClass().getSimpleName() + "(" + this.getElementType().toString() + ")"; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSuperStatement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSuperStatement.java deleted file mode 100644 index c0948dc9..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliSuperStatement.java +++ /dev/null @@ -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 org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliSuperStatement extends SmaliCompositeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliSuperStatement(); - } - }; - - public SmaliSuperStatement() { - super(SmaliElementTypes.SUPER_STATEMENT); - } - - @Nullable - public SmaliClassTypeElement getClassReference() { - return findChildByClass(SmaliClassTypeElement.class); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliThrowsList.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliThrowsList.java deleted file mode 100644 index 9cff5c34..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliThrowsList.java +++ /dev/null @@ -1,56 +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 com.intellij.lang.ASTNode; -import com.intellij.psi.PsiReferenceList; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.stub.SmaliThrowsListStub; - -public class SmaliThrowsList extends SmaliBaseReferenceList implements PsiReferenceList { - public SmaliThrowsList(@NotNull ASTNode node) { - super(node); - } - - public SmaliThrowsList(@NotNull SmaliThrowsListStub stub) { - super(stub, SmaliElementTypes.THROWS_LIST); - } - - @NotNull @Override public SmaliClassTypeElement[] getReferenceElements() { - return SmaliClassTypeElement.EMPTY_ARRAY; - } - - @Override public Role getRole() { - return null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliTypeElement.java deleted file mode 100644 index 634cf1a8..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliTypeElement.java +++ /dev/null @@ -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.psi.PsiAnnotation; -import com.intellij.psi.PsiJavaCodeReferenceElement; -import com.intellij.psi.PsiTypeElement; -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public abstract class SmaliTypeElement extends SmaliCompositeElement implements PsiTypeElement { - protected SmaliTypeElement(IElementType type) { - super(type); - } - - @Nullable @Override public PsiJavaCodeReferenceElement getInnermostComponentReferenceElement() { - return null; - } - - @NotNull - public String getSmaliName() { - return getText(); - } - - // Annotations on types are for JSR 308. Not applicable to smali. - - @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(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliVoidTypeElement.java b/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliVoidTypeElement.java deleted file mode 100644 index 2b540c6b..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/impl/SmaliVoidTypeElement.java +++ /dev/null @@ -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.PsiType; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliCompositeElementFactory; -import org.jf.smalidea.psi.SmaliElementTypes; - -public class SmaliVoidTypeElement extends SmaliTypeElement { - public static final SmaliCompositeElementFactory FACTORY = new SmaliCompositeElementFactory() { - @Override public SmaliCompositeElement createElement() { - return new SmaliVoidTypeElement(); - } - }; - - public SmaliVoidTypeElement() { - super(SmaliElementTypes.VOID_TYPE); - } - - @NotNull @Override public PsiType getType() { - return PsiType.VOID; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassFinder.java b/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassFinder.java deleted file mode 100644 index 87b2afff..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassFinder.java +++ /dev/null @@ -1,69 +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.index; - -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElementFinder; -import com.intellij.psi.search.GlobalSearchScope; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliClass; - -import java.util.Collection; - -public class SmaliClassFinder extends PsiElementFinder { - - private final Project project; - - public SmaliClassFinder(Project project) { - this.project = project; - } - - @Override - public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { - Collection classes = SmaliClassNameIndex.INSTANCE.get(qualifiedName, project, scope); - if (classes != null && classes.size() == 1) { - return classes.iterator().next(); - } - return null; - } - - @NotNull - @Override - public PsiClass[] findClasses(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { - PsiClass cls = findClass(qualifiedName, scope); - if (cls != null) { - return new PsiClass[] {cls}; - } - return PsiClass.EMPTY_ARRAY; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassNameIndex.java b/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassNameIndex.java deleted file mode 100644 index 0429597a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/index/SmaliClassNameIndex.java +++ /dev/null @@ -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.psi.index; - -import com.intellij.psi.stubs.StringStubIndexExtension; -import com.intellij.psi.stubs.StubIndexKey; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliClass; - -public class SmaliClassNameIndex extends StringStubIndexExtension { - public static final StubIndexKey KEY = - StubIndexKey.createIndexKey("smali.class.name"); - - public static final SmaliClassNameIndex INSTANCE = new SmaliClassNameIndex(); - - private SmaliClassNameIndex() { - } - - @NotNull @Override public StubIndexKey getKey() { - return KEY; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliClassDescriptor.java b/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliClassDescriptor.java deleted file mode 100644 index 36c59f23..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliClassDescriptor.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.jf.smalidea.psi.leaf; - -import com.intellij.psi.PsiIdentifier; -import com.intellij.psi.impl.source.tree.LeafPsiElement; -import com.intellij.psi.tree.IElementType; -import org.jf.smalidea.SmaliTokens; - -public class SmaliClassDescriptor extends LeafPsiElement implements PsiIdentifier { - public SmaliClassDescriptor(CharSequence text) { - super(SmaliTokens.CLASS_DESCRIPTOR, text); - } - - @Override - public IElementType getTokenType() { - return SmaliTokens.CLASS_DESCRIPTOR; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliSimpleName.java b/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliSimpleName.java deleted file mode 100644 index 84b2e501..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/leaf/SmaliSimpleName.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.jf.smalidea.psi.leaf; - -import com.intellij.psi.impl.source.tree.LeafPsiElement; -import org.jf.smalidea.SmaliTokens; - -public class SmaliSimpleName extends LeafPsiElement { - public SmaliSimpleName(CharSequence text) { - super(SmaliTokens.SIMPLE_NAME, text); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliAnnotationStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliAnnotationStub.java deleted file mode 100644 index d20882ce..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliAnnotationStub.java +++ /dev/null @@ -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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliAnnotation; - -public class SmaliAnnotationStub extends StubBase { - @Nullable - private final String annotationSmaliTypeName; - - public SmaliAnnotationStub(StubElement parent, @Nullable String annotationSmaliTypeName) { - super(parent, SmaliElementTypes.ANNOTATION); - this.annotationSmaliTypeName = annotationSmaliTypeName; - } - - @Nullable - public String getAnnotationSmaliTypeName() { - return annotationSmaliTypeName; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliBaseReferenceListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliBaseReferenceListStub.java deleted file mode 100644 index 8521c4b4..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliBaseReferenceListStub.java +++ /dev/null @@ -1,69 +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.stub; - -import com.intellij.psi.PsiManager; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.impl.LightSmaliClassTypeElement; -import org.jf.smalidea.psi.impl.SmaliBaseReferenceList; -import org.jf.smalidea.psi.impl.SmaliClassType; - -public abstract class SmaliBaseReferenceListStub extends StubBase { - @NotNull private final String[] smaliTypeNames; - @Nullable private SmaliClassType[] classTypes = null; - - protected SmaliBaseReferenceListStub( - @NotNull StubElement parent, @NotNull IStubElementType elementType, @NotNull String[] smaliTypeNames) { - super(parent, elementType); - this.smaliTypeNames = smaliTypeNames; - } - - @NotNull public String[] getSmaliTypeNames() { - return smaliTypeNames; - } - - @NotNull - public SmaliClassType[] getReferencedTypes() { - if (classTypes == null) { - classTypes = new SmaliClassType[smaliTypeNames.length]; - for (int i = 0; i< smaliTypeNames.length; i++) { - classTypes[i] = new SmaliClassType( - new LightSmaliClassTypeElement(PsiManager.getInstance(getProject()), smaliTypeNames[i])); - } - } - return classTypes; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStatementStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStatementStub.java deleted file mode 100644 index 41faccf2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStatementStub.java +++ /dev/null @@ -1,62 +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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliClassStatement; - -public class SmaliClassStatementStub extends StubBase { - @Nullable private final String qualifiedName; - - public SmaliClassStatementStub(StubElement parent, @Nullable String qualifiedName) { - super(parent, SmaliElementTypes.CLASS_STATEMENT); - this.qualifiedName = qualifiedName; - } - - @Nullable public String getQualifiedName() { - return qualifiedName; - } - - @Nullable public String getName() { - if (qualifiedName == null) { - return null; - } - int lastDot = qualifiedName.lastIndexOf('.'); - if (lastDot < 0) { - return qualifiedName; - } - return qualifiedName.substring(lastDot+1); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStub.java deleted file mode 100644 index b1656a59..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliClassStub.java +++ /dev/null @@ -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.psi.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliClass; - -public class SmaliClassStub extends StubBase { - public SmaliClassStub(StubElement parent) { - super(parent, SmaliElementTypes.CLASS); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliExtendsListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliExtendsListStub.java deleted file mode 100644 index 9678a29e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliExtendsListStub.java +++ /dev/null @@ -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.psi.stub; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliExtendsList; - -public class SmaliExtendsListStub extends SmaliBaseReferenceListStub { - public SmaliExtendsListStub(@NotNull StubElement parent, @NotNull String[] smaliTypeNames) { - super(parent, SmaliElementTypes.EXTENDS_LIST, smaliTypeNames); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFieldStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFieldStub.java deleted file mode 100644 index 15e0fbf0..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFieldStub.java +++ /dev/null @@ -1,58 +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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliField; - -public class SmaliFieldStub extends StubBase { - @Nullable private final String name; - @NotNull private final String smaliTypeName; - - public SmaliFieldStub(StubElement parent, @Nullable String name, @NotNull String smaliTypeName) { - super(parent, SmaliElementTypes.FIELD); - this.name = name; - this.smaliTypeName = smaliTypeName; - } - - @Nullable public String getName() { - return name; - } - - @NotNull public String getSmaliTypeName() { - return smaliTypeName; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFileStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFileStub.java deleted file mode 100644 index be059768..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliFileStub.java +++ /dev/null @@ -1,41 +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.stub; - -import com.intellij.psi.stubs.PsiFileStubImpl; -import org.jf.smalidea.psi.impl.SmaliFile; - -public class SmaliFileStub extends PsiFileStubImpl { - public SmaliFileStub(SmaliFile file) { - super(file); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliImplementsListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliImplementsListStub.java deleted file mode 100644 index 2b762c9f..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliImplementsListStub.java +++ /dev/null @@ -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.psi.stub; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliImplementsList; - -public class SmaliImplementsListStub extends SmaliBaseReferenceListStub { - public SmaliImplementsListStub(@NotNull StubElement parent, @NotNull String[] smaliTypeNames) { - super(parent, SmaliElementTypes.IMPLEMENTS_LIST, smaliTypeNames); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParamListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParamListStub.java deleted file mode 100644 index f4878660..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParamListStub.java +++ /dev/null @@ -1,44 +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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliMethodPrototype; - -public class SmaliMethodParamListStub extends StubBase { - public SmaliMethodParamListStub(@NotNull StubElement parent) { - super(parent, SmaliElementTypes.METHOD_PARAM_LIST); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParameterStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParameterStub.java deleted file mode 100644 index e6f1cf25..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodParameterStub.java +++ /dev/null @@ -1,58 +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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliMethodParameter; - -public class SmaliMethodParameterStub extends StubBase { - @NotNull private final String smaliTypeName; - @Nullable private final String name; - - public SmaliMethodParameterStub(@NotNull StubElement parent, @NotNull String smaliTypeName, @Nullable String name) { - super(parent, SmaliElementTypes.METHOD_PARAMETER); - this.smaliTypeName = smaliTypeName; - this.name = name; - } - - @NotNull public String getSmaliTypeName() { - return smaliTypeName; - } - - @Nullable public String getName() { - return name; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java deleted file mode 100644 index ac0b1e9a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodPrototypeStub.java +++ /dev/null @@ -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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliMethodPrototype; - -public class SmaliMethodPrototypeStub extends StubBase { - @Nullable private final String returnSmaliTypeName; - - public SmaliMethodPrototypeStub(@NotNull StubElement parent, @Nullable String returnSmaliTypeName) { - super(parent, SmaliElementTypes.METHOD_PROTOTYPE); - this.returnSmaliTypeName = returnSmaliTypeName; - } - - @Nullable public String getReturnSmaliTypeName() { - return returnSmaliTypeName; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java deleted file mode 100644 index 1412980a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliMethodStub.java +++ /dev/null @@ -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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliMethod; - -import javax.annotation.Nullable; - -public class SmaliMethodStub extends StubBase { - @Nullable private final String name; - - public SmaliMethodStub(@NotNull StubElement parent, @Nullable String name) { - super(parent, SmaliElementTypes.METHOD); - this.name = name; - } - - @Nullable public String getName() { - return name; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliModifierListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliModifierListStub.java deleted file mode 100644 index e0a5f0e4..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliModifierListStub.java +++ /dev/null @@ -1,50 +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.stub; - -import com.intellij.psi.stubs.StubBase; -import com.intellij.psi.stubs.StubElement; -import org.jf.smalidea.psi.impl.SmaliMethod; -import org.jf.smalidea.psi.stub.element.SmaliModifierListElementType; - -public class SmaliModifierListStub extends StubBase { - private final int accessFlags; - - public SmaliModifierListStub(StubElement parent, int accessFlags) { - super(parent, SmaliModifierListElementType.INSTANCE); - this.accessFlags = accessFlags; - } - - public int getAccessFlags() { - return accessFlags; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliThrowsListStub.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliThrowsListStub.java deleted file mode 100644 index 94d239ec..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/SmaliThrowsListStub.java +++ /dev/null @@ -1,43 +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.stub; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.SmaliElementTypes; -import org.jf.smalidea.psi.impl.SmaliThrowsList; - -public class SmaliThrowsListStub extends SmaliBaseReferenceListStub { - public SmaliThrowsListStub(@NotNull StubElement parent) { - super(parent, SmaliElementTypes.THROWS_LIST, new String[0]); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliAnnotationElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliAnnotationElementType.java deleted file mode 100644 index 7085cc0e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliAnnotationElementType.java +++ /dev/null @@ -1,80 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliAnnotation; -import org.jf.smalidea.psi.stub.SmaliAnnotationStub; - -import java.io.IOException; - -public class SmaliAnnotationElementType extends SmaliStubElementType { - public static final SmaliAnnotationElementType INSTANCE = new SmaliAnnotationElementType(); - - private SmaliAnnotationElementType() { - super("ANNOTATION"); - } - - @NotNull @Override public String getExternalId() { - return "smali.annotation"; - } - - @Override public SmaliAnnotation createPsi(@NotNull SmaliAnnotationStub stub) { - return new SmaliAnnotation(stub); - } - - @Override public SmaliAnnotation createPsi(@NotNull ASTNode node) { - return new SmaliAnnotation(node); - } - - @Override public SmaliAnnotationStub createStub(@NotNull SmaliAnnotation psi, StubElement parentStub) { - return new SmaliAnnotationStub(parentStub, psi.getSmaliName()); - } - - @Override - public void serialize(@NotNull SmaliAnnotationStub stub, @NotNull StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getAnnotationSmaliTypeName()); - } - - @NotNull @Override - public SmaliAnnotationStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - return new SmaliAnnotationStub(parentStub, deserializeNullableString(dataStream)); - } - - @Override public void indexStub(@NotNull SmaliAnnotationStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliBaseReferenceListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliBaseReferenceListElementType.java deleted file mode 100644 index d73a33a1..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliBaseReferenceListElementType.java +++ /dev/null @@ -1,76 +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.stub.element; - -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliBaseReferenceList; -import org.jf.smalidea.psi.stub.SmaliBaseReferenceListStub; - -import java.io.IOException; - -public abstract class SmaliBaseReferenceListElementType extends SmaliStubElementType { - - protected SmaliBaseReferenceListElementType(@NotNull @NonNls String debugName) { - super(debugName); - } - - @Override - public void serialize(@NotNull StubT stub, @NotNull StubOutputStream dataStream) - throws IOException { - String[] references = stub.getSmaliTypeNames(); - dataStream.writeVarInt(references.length); - for (String reference: references) { - dataStream.writeName(reference); - } - } - - @NotNull @Override - public StubT deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - String[] smaliTypeNames = new String[dataStream.readVarInt()]; - for (int i=0; i { - public static final SmaliClassElementType INSTANCE = new SmaliClassElementType(); - - private SmaliClassElementType() { - super("CLASS"); - } - - @NotNull @Override public String getExternalId() { - return "smali.class"; - } - - @Override public SmaliClass createPsi(@NotNull SmaliClassStub stub) { - return new SmaliClass(stub); - } - - @Override public SmaliClass createPsi(@NotNull ASTNode node) { - return new SmaliClass(node); - } - - @Override public SmaliClassStub createStub(@NotNull SmaliClass psi, StubElement parentStub) { - return new SmaliClassStub(parentStub); - } - - @Override - public void serialize(@NotNull SmaliClassStub stub, @NotNull StubOutputStream dataStream) throws IOException { - - } - - @NotNull @Override - public SmaliClassStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - return new SmaliClassStub(parentStub); - } - - @Override public void indexStub(@NotNull SmaliClassStub stub, @NotNull IndexSink sink) { - SmaliClassStatementStub smaliClassStatementStub = - (SmaliClassStatementStub)stub.findChildStubByType(SmaliElementTypes.CLASS_STATEMENT); - if (smaliClassStatementStub != null) { - String qualifiedName = smaliClassStatementStub.getQualifiedName(); - if (qualifiedName != null) { - sink.occurrence(SmaliClassNameIndex.KEY, qualifiedName); - } - - final String shortName = smaliClassStatementStub.getName(); - if (shortName != null) { - sink.occurrence(JavaStubIndexKeys.CLASS_SHORT_NAMES, shortName); - } - } - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliClassStatementElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliClassStatementElementType.java deleted file mode 100644 index f3029c06..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliClassStatementElementType.java +++ /dev/null @@ -1,80 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliClassStatement; -import org.jf.smalidea.psi.stub.SmaliClassStatementStub; - -import java.io.IOException; - -public class SmaliClassStatementElementType extends SmaliStubElementType { - public static final SmaliClassStatementElementType INSTANCE = new SmaliClassStatementElementType(); - - public SmaliClassStatementElementType() { - super("CLASS_STATEMENT"); - } - - @Override public SmaliClassStatement createPsi(@NotNull ASTNode node) { - return new SmaliClassStatement(node); - } - - @Override public SmaliClassStatement createPsi(@NotNull SmaliClassStatementStub stub) { - return new SmaliClassStatement(stub); - } - - @Override public SmaliClassStatementStub createStub(@NotNull SmaliClassStatement psi, StubElement parentStub) { - return new SmaliClassStatementStub(parentStub, psi.getQualifiedName()); - } - - @NotNull @Override public String getExternalId() { - return "smali.class_statement"; - } - - @Override - public void serialize(@NotNull SmaliClassStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getQualifiedName()); - } - - @NotNull @Override - public SmaliClassStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - return new SmaliClassStatementStub(parentStub, deserializeNullableString(dataStream)); - } - - @Override public void indexStub(@NotNull SmaliClassStatementStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliExtendsListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliExtendsListElementType.java deleted file mode 100644 index 3acfd8fd..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliExtendsListElementType.java +++ /dev/null @@ -1,66 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliExtendsList; -import org.jf.smalidea.psi.stub.SmaliExtendsListStub; - -public class SmaliExtendsListElementType extends SmaliBaseReferenceListElementType { - public static final SmaliExtendsListElementType INSTANCE = new SmaliExtendsListElementType (); - - private SmaliExtendsListElementType() { - super("EXTENDS_LIST"); - } - - @NotNull @Override public String getExternalId() { - return "smali.extends_list"; - } - - @Override public SmaliExtendsList createPsi(@NotNull SmaliExtendsListStub stub) { - return new SmaliExtendsList(stub); - } - - @Override public SmaliExtendsList createPsi(@NotNull ASTNode node) { - return new SmaliExtendsList(node); - } - - @Override protected SmaliExtendsListStub createStub(StubElement parentStub, String[] smaliTypeNames) { - return new SmaliExtendsListStub(parentStub, smaliTypeNames); - } - - @Override public SmaliExtendsListStub createStub(@NotNull SmaliExtendsList psi, StubElement parentStub) { - return new SmaliExtendsListStub(parentStub, psi.getSmaliNames()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFieldElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFieldElementType.java deleted file mode 100644 index 235e995d..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFieldElementType.java +++ /dev/null @@ -1,97 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.openapi.project.IndexNotReadyException; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliField; -import org.jf.smalidea.psi.impl.SmaliTypeElement; -import org.jf.smalidea.psi.stub.SmaliFieldStub; - -import java.io.IOException; - -public class SmaliFieldElementType extends SmaliStubElementType { - public static final SmaliFieldElementType INSTANCE = new SmaliFieldElementType(); - - private SmaliFieldElementType() { - super("FIELD"); - } - - @NotNull @Override public String getExternalId() { - return "smali.field"; - } - - @Override public SmaliField createPsi(@NotNull SmaliFieldStub stub) { - return new SmaliField(stub); - } - - @Override public SmaliField createPsi(@NotNull ASTNode node) { - return new SmaliField(node); - } - - @Override public SmaliFieldStub createStub(@NotNull SmaliField psi, StubElement parentStub) { - try { - String fieldSmaliTypeName; - SmaliTypeElement typeElement = psi.getTypeElement(); - if (typeElement != null) { - fieldSmaliTypeName = typeElement.getSmaliName(); - } else { - fieldSmaliTypeName = "Ljava/lang/Object;"; - } - - return new SmaliFieldStub(parentStub, psi.getName(), fieldSmaliTypeName); - } catch (IndexNotReadyException ex) { - System.out.println(psi.getName()); - throw ex; - } - } - - @Override - public void serialize(@NotNull SmaliFieldStub stub, @NotNull StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeName(stub.getSmaliTypeName()); - } - - @NotNull @Override - public SmaliFieldStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - return new SmaliFieldStub(parentStub, deserializeNullableString(dataStream), - dataStream.readName().getString()); - } - - @Override public void indexStub(@NotNull SmaliFieldStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFileElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFileElementType.java deleted file mode 100644 index 3e1eaf59..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliFileElementType.java +++ /dev/null @@ -1,62 +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.stub.element; - -import com.intellij.psi.PsiFile; -import com.intellij.psi.StubBuilder; -import com.intellij.psi.stubs.DefaultStubBuilder; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.tree.IStubFileElementType; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.SmaliLanguage; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.stub.SmaliFileStub; - -public class SmaliFileElementType extends IStubFileElementType { - public static final SmaliFileElementType INSTANCE = new SmaliFileElementType(); - - private SmaliFileElementType() { - super("smali.FILE", SmaliLanguage.INSTANCE); - } - - @Override public StubBuilder getBuilder() { - return new DefaultStubBuilder() { - @Override - protected StubElement createStubForFile(@NotNull PsiFile file) { - if (file instanceof SmaliFile) { - return new SmaliFileStub((SmaliFile)file); - } - throw new RuntimeException("Unexpected file type"); - } - }; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliImplementsListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliImplementsListElementType.java deleted file mode 100644 index 3b17bc1a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliImplementsListElementType.java +++ /dev/null @@ -1,67 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliImplementsList; -import org.jf.smalidea.psi.stub.SmaliImplementsListStub; - -public class SmaliImplementsListElementType - extends SmaliBaseReferenceListElementType { - public static final SmaliImplementsListElementType INSTANCE = new SmaliImplementsListElementType(); - - private SmaliImplementsListElementType() { - super("IMPLEMENTS_LIST"); - } - - @NotNull @Override public String getExternalId() { - return "smali.implements_list"; - } - - @Override public SmaliImplementsList createPsi(@NotNull SmaliImplementsListStub stub) { - return new SmaliImplementsList(stub); - } - - @Override public SmaliImplementsList createPsi(@NotNull ASTNode node) { - return new SmaliImplementsList(node); - } - - @Override protected SmaliImplementsListStub createStub(StubElement parentStub, String[] smaliTypeNames) { - return new SmaliImplementsListStub(parentStub, smaliTypeNames); - } - - @Override public SmaliImplementsListStub createStub(@NotNull SmaliImplementsList psi, StubElement parentStub) { - return new SmaliImplementsListStub(parentStub, psi.getSmaliNames()); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java deleted file mode 100644 index 1d83f1a2..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodElementType.java +++ /dev/null @@ -1,80 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliMethod; -import org.jf.smalidea.psi.stub.SmaliMethodStub; - -import java.io.IOException; - -public class SmaliMethodElementType extends SmaliStubElementType { - public static final SmaliMethodElementType INSTANCE = new SmaliMethodElementType(); - - private SmaliMethodElementType() { - super("METHOD"); - } - - @NotNull @Override public String getExternalId() { - return "smali.method"; - } - - @Override public SmaliMethod createPsi(@NotNull SmaliMethodStub stub) { - return new SmaliMethod(stub); - } - - @Override public SmaliMethod createPsi(@NotNull ASTNode node) { - return new SmaliMethod(node); - } - - @Override public SmaliMethodStub createStub(@NotNull SmaliMethod psi, StubElement parentStub) { - return new SmaliMethodStub(parentStub, psi.getName()); - } - - @Override - public void serialize(@NotNull SmaliMethodStub stub, @NotNull StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getName()); - } - - @NotNull @Override - public SmaliMethodStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - return new SmaliMethodStub(parentStub, dataStream.readName().getString()); - } - - @Override public void indexStub(@NotNull SmaliMethodStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParamListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParamListElementType.java deleted file mode 100644 index 197e682e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParamListElementType.java +++ /dev/null @@ -1,82 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliMethodParamList; -import org.jf.smalidea.psi.stub.SmaliMethodParamListStub; - -import java.io.IOException; - -public class SmaliMethodParamListElementType - extends SmaliStubElementType { - public static final SmaliMethodParamListElementType INSTANCE = new SmaliMethodParamListElementType(); - - private SmaliMethodParamListElementType() { - super("METHOD_PARAM_LIST"); - } - - @NotNull @Override public String getExternalId() { - return "smali.method_param_list"; - } - - @Override public SmaliMethodParamList createPsi(@NotNull ASTNode node) { - return new SmaliMethodParamList(node); - } - - @Override public SmaliMethodParamList createPsi(@NotNull SmaliMethodParamListStub stub) { - return new SmaliMethodParamList(stub); - } - - @Override public SmaliMethodParamListStub createStub(@NotNull SmaliMethodParamList psi, StubElement parentStub) { - return new SmaliMethodParamListStub(parentStub); - } - - @Override - public void serialize(@NotNull SmaliMethodParamListStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - } - - @NotNull @Override - public SmaliMethodParamListStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - return new SmaliMethodParamListStub(parentStub); - } - - @Override public void indexStub(@NotNull SmaliMethodParamListStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParameterElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParameterElementType.java deleted file mode 100644 index ca5a0106..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodParameterElementType.java +++ /dev/null @@ -1,85 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliMethodParameter; -import org.jf.smalidea.psi.stub.SmaliMethodParameterStub; - -import java.io.IOException; - -public class SmaliMethodParameterElementType - extends SmaliStubElementType { - public static final SmaliMethodParameterElementType INSTANCE = new SmaliMethodParameterElementType(); - - private SmaliMethodParameterElementType() { - super("METHOD_PARAMETER"); - } - - @NotNull @Override public String getExternalId() { - return "smali.method_parameter"; - } - - @Override public SmaliMethodParameter createPsi(@NotNull ASTNode node) { - return new SmaliMethodParameter(node); - } - - @Override public SmaliMethodParameter createPsi(@NotNull SmaliMethodParameterStub stub) { - return new SmaliMethodParameter(stub); - } - - @Override public SmaliMethodParameterStub createStub(@NotNull SmaliMethodParameter psi, StubElement parentStub) { - return new SmaliMethodParameterStub(parentStub, psi.getTypeElement().getSmaliName(), psi.getName()); - } - - @Override - public void serialize(@NotNull SmaliMethodParameterStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getSmaliTypeName()); - dataStream.writeName(stub.getName()); - } - - @NotNull @Override - public SmaliMethodParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - return new SmaliMethodParameterStub(parentStub, dataStream.readName().getString(), - deserializeNullableString(dataStream)); - } - - @Override public void indexStub(@NotNull SmaliMethodParameterStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java deleted file mode 100644 index 290b78ca..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliMethodPrototypeElementType.java +++ /dev/null @@ -1,90 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliMethodPrototype; -import org.jf.smalidea.psi.impl.SmaliTypeElement; -import org.jf.smalidea.psi.stub.SmaliMethodPrototypeStub; - -import java.io.IOException; - -public class SmaliMethodPrototypeElementType - extends SmaliStubElementType { - public static final SmaliMethodPrototypeElementType INSTANCE = new SmaliMethodPrototypeElementType(); - - private SmaliMethodPrototypeElementType() { - super("METHOD_PROTOTYPE"); - } - - @NotNull @Override public String getExternalId() { - return "smali.method_prototype"; - } - - @Override public SmaliMethodPrototype createPsi(@NotNull ASTNode node) { - return new SmaliMethodPrototype(node); - } - - @Override public SmaliMethodPrototype createPsi(@NotNull SmaliMethodPrototypeStub stub) { - return new SmaliMethodPrototype(stub); - } - - @Override public SmaliMethodPrototypeStub createStub(@NotNull SmaliMethodPrototype psi, StubElement parentStub) { - SmaliTypeElement returnType = psi.getReturnTypeElement(); - String returnSmaliTypeName = null; - if (returnType != null) { - returnSmaliTypeName = returnType.getSmaliName(); - } - - return new SmaliMethodPrototypeStub(parentStub, returnSmaliTypeName); - } - - @Override - public void serialize(@NotNull SmaliMethodPrototypeStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getReturnSmaliTypeName()); - } - - @NotNull @Override - public SmaliMethodPrototypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - return new SmaliMethodPrototypeStub(parentStub, deserializeNullableString(dataStream)); - } - - @Override public void indexStub(@NotNull SmaliMethodPrototypeStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliModifierListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliModifierListElementType.java deleted file mode 100644 index 12299b4a..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliModifierListElementType.java +++ /dev/null @@ -1,82 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliModifierList; -import org.jf.smalidea.psi.stub.SmaliModifierListStub; - -import java.io.IOException; - -public class SmaliModifierListElementType extends SmaliStubElementType { - public static final SmaliModifierListElementType INSTANCE = new SmaliModifierListElementType(); - - private SmaliModifierListElementType() { - super("MODIFIER_LIST"); - } - - @NotNull @Override public String getExternalId() { - return "smali.modifier_list"; - } - - @Override public SmaliModifierList createPsi(@NotNull SmaliModifierListStub stub) { - return new SmaliModifierList(stub); - } - - @Override public SmaliModifierList createPsi(@NotNull ASTNode node) { - return new SmaliModifierList(node); - } - - @Override public SmaliModifierListStub createStub(@NotNull SmaliModifierList psi, StubElement parentStub) { - return new SmaliModifierListStub(parentStub, psi.getAccessFlags()); - } - - @Override - public void serialize(@NotNull SmaliModifierListStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeVarInt(stub.getAccessFlags()); - } - - @NotNull @Override - public SmaliModifierListStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - return new SmaliModifierListStub(parentStub, dataStream.readVarInt()); - } - - @Override public void indexStub(@NotNull SmaliModifierListStub stub, @NotNull IndexSink sink) { - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliStubElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliStubElementType.java deleted file mode 100644 index 51544b49..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliStubElementType.java +++ /dev/null @@ -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.psi.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.smalidea.SmaliLanguage; - -import java.io.IOException; - -public abstract class SmaliStubElementType - extends IStubElementType { - protected SmaliStubElementType(@NotNull @NonNls String debugName) { - super(debugName, SmaliLanguage.INSTANCE); - } - - public abstract PsiT createPsi(@NotNull ASTNode node); - - @Nullable - protected String deserializeNullableString(@NotNull StubInputStream dataStream) throws IOException { - StringRef stringRef = dataStream.readName(); - if (stringRef == null) { - return null; - } - return stringRef.getString(); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliThrowsListElementType.java b/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliThrowsListElementType.java deleted file mode 100644 index b53af341..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/psi/stub/element/SmaliThrowsListElementType.java +++ /dev/null @@ -1,67 +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.stub.element; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliThrowsList; -import org.jf.smalidea.psi.stub.SmaliThrowsListStub; - -public class SmaliThrowsListElementType - extends SmaliBaseReferenceListElementType { - public static final SmaliThrowsListElementType INSTANCE = new SmaliThrowsListElementType(); - - private SmaliThrowsListElementType() { - super("THROWS_LIST"); - } - - @NotNull @Override public String getExternalId() { - return "smali.throws_list"; - } - - @Override public SmaliThrowsList createPsi(@NotNull SmaliThrowsListStub stub) { - return new SmaliThrowsList(stub); - } - - @Override public SmaliThrowsList createPsi(@NotNull ASTNode node) { - return new SmaliThrowsList(node); - } - - @Override protected SmaliThrowsListStub createStub(StubElement parentStub, String[] types) { - return new SmaliThrowsListStub(parentStub); - } - - @Override public SmaliThrowsListStub createStub(@NotNull SmaliThrowsList psi, StubElement parentStub) { - return new SmaliThrowsListStub(parentStub); - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/util/InstructionUtils.java b/smalidea/src/main/java/org/jf/smalidea/util/InstructionUtils.java deleted file mode 100644 index e302b01e..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/util/InstructionUtils.java +++ /dev/null @@ -1,66 +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.util; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jf.dexlib2.Opcode; -import org.jf.smalidea.psi.impl.SmaliInstruction; -import org.jf.smalidea.psi.impl.SmaliLabel; -import org.jf.smalidea.psi.impl.SmaliLabelReference; -import org.jf.smalidea.psi.impl.SmaliMethod; - -public class InstructionUtils { - - @Nullable - public static SmaliInstruction findFirstInstructionWithTarget( - @NotNull SmaliMethod method, @NotNull Opcode opcode, int targetOffset) { - for (SmaliInstruction instruction: method.getInstructions()) { - if (instruction.getOpcode() == opcode) { - SmaliLabelReference labelReference = instruction.getTarget(); - if (labelReference == null) { - continue; - } - - SmaliLabel label = labelReference.resolve(); - if (label == null) { - continue; - } - - if (label.getOffset() == targetOffset) { - return instruction; - } - } - } - return null; - } -} diff --git a/smalidea/src/main/java/org/jf/smalidea/util/NameUtils.java b/smalidea/src/main/java/org/jf/smalidea/util/NameUtils.java deleted file mode 100644 index 47cb08ca..00000000 --- a/smalidea/src/main/java/org/jf/smalidea/util/NameUtils.java +++ /dev/null @@ -1,339 +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.util; - -import com.google.common.collect.ImmutableMap; -import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.impl.ResolveScopeManager; -import com.intellij.psi.search.GlobalSearchScope; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; - -public class NameUtils { - private static final Map javaToSmaliPrimitiveTypes = ImmutableMap.builder() - .put("boolean", "Z") - .put("byte", "B") - .put("char", "C") - .put("short", "S") - .put("int", "I") - .put("long", "J") - .put("float", "F") - .put("double", "D") - .build(); - - @NotNull - public static String javaToSmaliType(@NotNull PsiType psiType) { - if (psiType instanceof PsiClassType) { - PsiClass psiClass = ((PsiClassType)psiType).resolve(); - if (psiClass != null) { - return javaToSmaliType(psiClass); - } - } - return javaToSmaliType(psiType.getCanonicalText()); - } - - @NotNull - public static String javaToSmaliType(@NotNull PsiClass psiClass) { - String qualifiedName = psiClass.getQualifiedName(); - if (qualifiedName == null) { - throw new IllegalArgumentException("This method does not support anonymous classes"); - } - PsiClass parent = psiClass.getContainingClass(); - if (parent != null) { - int offset = qualifiedName.lastIndexOf('.'); - String parentName = qualifiedName.substring(0, offset); - assert parentName.equals(parent.getQualifiedName()); - String className = qualifiedName.substring(offset+1, qualifiedName.length()); - assert className.equals(psiClass.getName()); - return javaToSmaliType(parentName + '$' + className); - } else { - return javaToSmaliType(psiClass.getQualifiedName()); - } - } - - @NotNull - public static String javaToSmaliType(@NotNull String javaType) { - if (javaType.charAt(javaType.length()-1) == ']') { - int dimensions = 0; - int firstArrayChar = -1; - for (int i=0; i 0) { - StringBuilder sb = new StringBuilder(firstArrayChar + 2 + dimensions); - for (int i=0; i 0 && offset < javaType.length()-1) { - String left = javaType.substring(0, offset); - psiClass = facade.findClass(left, scope); - if (psiClass != null) { - psiClass = findInnerClass(psiClass, javaType.substring(offset+1, javaType.length()), facade, scope); - if (psiClass != null) { - return psiClass; - } - } - offset = javaType.indexOf('$', offset+1); - } - return null; - } - - @Nullable - public static PsiClass resolveSmaliType(@NotNull PsiElement element, @NotNull String smaliType) { - GlobalSearchScope scope = ResolveScopeManager.getElementResolveScope(element); - return resolveSmaliType(element.getProject(), scope, smaliType); - } - - @Nullable - public static PsiClass findInnerClass(@NotNull PsiClass outerClass, String innerText, JavaPsiFacade facade, - GlobalSearchScope scope) { - int offset = innerText.indexOf('$'); - if (offset < 0) { - offset = innerText.length(); - } - - while (offset > 0 && offset <= innerText.length()) { - String left = innerText.substring(0, offset); - String nextInner = outerClass.getQualifiedName() + "." + left; - PsiClass psiClass = facade.findClass(nextInner, scope); - if (psiClass != null) { - if (offset < innerText.length()) { - psiClass = findInnerClass(psiClass, innerText.substring(offset+1, innerText.length()), facade, - scope); - if (psiClass != null) { - return psiClass; - } - } else { - return psiClass; - } - } - if (offset >= innerText.length()) { - break; - } - offset = innerText.indexOf('$', offset+1); - if (offset < 0) { - offset = innerText.length(); - } - } - return null; - } - - private static String simpleJavaToSmaliType(@NotNull String simpleJavaType) { - StringBuilder sb = new StringBuilder(simpleJavaType.length() + 2); - convertSimpleJavaToSmaliType(simpleJavaType, sb); - sb.trimToSize(); - return sb.toString(); - } - - @NotNull - public static String smaliToJavaType(@NotNull String smaliType) { - if (smaliType.charAt(0) == '[') { - return convertSmaliArrayToJava(smaliType); - } else { - StringBuilder sb = new StringBuilder(smaliType.length()); - convertAndAppendNonArraySmaliTypeToJava(smaliType, sb); - return sb.toString(); - } - } - - @NotNull - public static String resolveSmaliToJavaType(@NotNull Project project, @NotNull GlobalSearchScope scope, - @NotNull String smaliType) { - // First, try to resolve the type and get its qualified name, so that we can make sure - // to use the correct name for inner classes - PsiClass resolvedType = resolveSmaliType(project, scope, smaliType); - if (resolvedType != null) { - String qualifiedName = resolvedType.getQualifiedName(); - if (qualifiedName != null) { - return qualifiedName; - } - } - - // if we can't find it, just do a textual conversion of the name - return smaliToJavaType(smaliType); - } - - @NotNull - public static String resolveSmaliToJavaType(@NotNull PsiElement element, @NotNull String smaliType) { - return resolveSmaliToJavaType(element.getProject(), element.getResolveScope(), smaliType); - } - - @NotNull - public static PsiType resolveSmaliToPsiType(@NotNull PsiElement element, @NotNull String smaliType) { - PsiClass resolvedType = resolveSmaliType(element, smaliType); - if (resolvedType != null) { - PsiElementFactory factory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory(); - return factory.createType(resolvedType); - } - - String javaType = NameUtils.smaliToJavaType(smaliType); - PsiElementFactory factory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory(); - return factory.createTypeFromText(javaType, element); - } - - @NotNull - private static String convertSmaliArrayToJava(@NotNull String smaliType) { - int dimensions=0; - while (smaliType.charAt(dimensions) == '[') { - dimensions++; - } - - StringBuilder sb = new StringBuilder(smaliType.length() + dimensions); - convertAndAppendNonArraySmaliTypeToJava(smaliType.substring(dimensions), sb); - for (int i=0; i - org.jf.smalidea - Smalidea - 0.04 - JesusFreke - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/smalidea/src/main/resources/icons/smali.png b/smalidea/src/main/resources/icons/smali.png deleted file mode 100644 index e60efc56..00000000 Binary files a/smalidea/src/main/resources/icons/smali.png and /dev/null differ diff --git a/smalidea/src/test/java/org/jf/smalidea/AnnotationElementNameReferenceTest.java b/smalidea/src/test/java/org/jf/smalidea/AnnotationElementNameReferenceTest.java deleted file mode 100644 index b11193a8..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/AnnotationElementNameReferenceTest.java +++ /dev/null @@ -1,104 +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; - -import com.intellij.psi.*; -import com.intellij.testFramework.ResolveTestCase; -import org.junit.Assert; - -public class AnnotationElementNameReferenceTest extends ResolveTestCase { - public void testSmaliReferenceFromSmali() throws Exception { - createFile("AnnotationWithValues.smali", "" + - ".class public abstract interface annotation LAnnotationWithValues;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract intValue()I\n" + - ".end method"); - - PsiReference reference = configureByFileText("" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".annotation runtime LAnnotationWithValues;\n" + - " intValue = 123\n" + - ".end annotation", "blah.smali"); - - PsiElement resolved = reference.resolve(); - Assert.assertNotNull(resolved); - Assert.assertTrue(resolved instanceof PsiAnnotationMethod); - Assert.assertEquals("intValue", ((PsiAnnotationMethod)resolved).getName()); - Assert.assertEquals("AnnotationWithValues", - ((PsiAnnotationMethod)resolved).getContainingClass().getQualifiedName()); - } - - public void testJavaReferenceFromSmali() throws Exception { - createFile("AnnotationWithValues.java", "" + - "public @interface AnnotationWithValues {\n" + - " int intValue();\n" + - "}"); - - PsiReference reference = configureByFileText("" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".annotation runtime LAnnotationWithValues;\n" + - " intValue = 123\n" + - ".end annotation", "blah.smali"); - - PsiElement resolved = reference.resolve(); - Assert.assertNotNull(resolved); - Assert.assertTrue(resolved instanceof PsiAnnotationMethod); - Assert.assertEquals("intValue", ((PsiAnnotationMethod)resolved).getName()); - Assert.assertEquals("AnnotationWithValues", - ((PsiAnnotationMethod)resolved).getContainingClass().getQualifiedName()); - } - - public void testSmaliReferenceFromJava() throws Exception { - createFile("AnnotationWithValues.smali", "" + - ".class public abstract interface annotation LAnnotationWithValues;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract intValue()I\n" + - ".end method"); - - PsiReference reference = configureByFileText("" + - "@AnnotationWithValues(intValue=123)\n" + - "public class blah {}", "blah.java"); - - PsiElement resolved = reference.resolve(); - Assert.assertNotNull(resolved); - Assert.assertTrue(resolved instanceof PsiAnnotationMethod); - Assert.assertEquals("intValue", ((PsiAnnotationMethod)resolved).getName()); - Assert.assertEquals("AnnotationWithValues", - ((PsiAnnotationMethod)resolved).getContainingClass().getQualifiedName()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/ClassMoveTest.java b/smalidea/src/test/java/org/jf/smalidea/ClassMoveTest.java deleted file mode 100644 index 89d45451..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/ClassMoveTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.jf.smalidea; - -import com.intellij.openapi.roots.JavaProjectRootsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.refactoring.MultiFileTestCase; -import com.intellij.refactoring.PackageWrapper; -import com.intellij.refactoring.move.moveClassesOrPackages.AutocreatingSingleSourceRootMoveDestination; -import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesProcessor; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class ClassMoveTest extends MultiFileTestCase { - @Override - protected String getTestDataPath() { - return "testData"; - } - - @NotNull - @Override - protected String getTestRoot() { - return "/classMove/"; - } - - public void testBasicFromNoPackage() { - doTest("blah", "my"); - } - - public void testBasicToNoPackage() { - doTest("my.blah", ""); - } - - private void doTest(@NotNull final String oldQualifiedName, @NotNull final String newPackage) { - doTest(new PerformAction() { - @Override - public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception { - doMove(oldQualifiedName, newPackage); - } - }); - } - - private void doMove(String oldQualifiedName, final String newPackage) throws Exception { - final PsiClass testClass = myJavaFacade.findClass(oldQualifiedName, GlobalSearchScope.allScope(getProject())); - - final List contentSourceRoots = - JavaProjectRootsUtil.getSuitableDestinationSourceRoots(getProject()); - - new MoveClassesOrPackagesProcessor(getProject(), new PsiClass[] {testClass}, - new AutocreatingSingleSourceRootMoveDestination(new PackageWrapper(getPsiManager(), newPackage), - contentSourceRoots.get(0)), false, false, null).run(); - } - -} diff --git a/smalidea/src/test/java/org/jf/smalidea/ClassReferenceTest.java b/smalidea/src/test/java/org/jf/smalidea/ClassReferenceTest.java deleted file mode 100644 index 9d61bf02..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/ClassReferenceTest.java +++ /dev/null @@ -1,133 +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.project.DumbServiceImpl; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.psi.JavaResolveResult; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiReference; -import com.intellij.testFramework.ResolveTestCase; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliClassTypeElement; -import org.junit.Assert; - -public class ClassReferenceTest extends ResolveTestCase { - /** - * Test a reference to a java class from a smali class - */ - public void testJavaReferenceFromSmali() throws Exception { - SmaliClassTypeElement typeElement = (SmaliClassTypeElement)configureByFileText( - ".class public Lblah; .super Ljava/lang/Object;", "blah.smali"); - - Assert.assertNotNull(typeElement); - Assert.assertEquals("Object", typeElement.getName()); - - PsiClass psiClass = typeElement.resolve(); - Assert.assertNotNull(psiClass); - Assert.assertEquals("java.lang.Object", psiClass.getQualifiedName()); - - JavaResolveResult resolveResult = typeElement.advancedResolve(false); - Assert.assertNotNull(resolveResult.getElement()); - Assert.assertEquals("java.lang.Object", ((PsiClass)resolveResult.getElement()).getQualifiedName()); - - JavaResolveResult[] resolveResults = typeElement.multiResolve(false); - Assert.assertEquals(1, resolveResults.length); - Assert.assertNotNull(resolveResults[0].getElement()); - Assert.assertEquals("java.lang.Object", ((PsiClass)resolveResults[0].getElement()).getQualifiedName()); - } - - /** - * Test a reference to a java class from a smali class, while in dumb mode - */ - public void testJavaReferenceFromSmaliInDumbMode() throws Exception { - SmaliClassTypeElement typeElement = (SmaliClassTypeElement)configureByFileText( - ".class public Lblah; .super Ljava/lang/Object;", "blah.smali"); - - Assert.assertNotNull(typeElement); - Assert.assertEquals("Object", typeElement.getName()); - - DumbServiceImpl.getInstance(getProject()).setDumb(true); - - PsiClass psiClass = typeElement.resolve(); - Assert.assertNull(psiClass); - - DumbServiceImpl.getInstance(getProject()).setDumb(false); - } - - /** - * Test a reference to a smali class from a smali class - */ - public void testSmaliReferenceFromSmali() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;"); - - SmaliClassTypeElement typeElement = (SmaliClassTypeElement)configureByFileText( - ".class public Lblah; .super Lblarg;", "blah.smali"); - - Assert.assertEquals("blarg", typeElement.getName()); - - SmaliClass smaliClass = (SmaliClass)typeElement.resolve(); - Assert.assertNotNull(smaliClass); - Assert.assertEquals("blarg", smaliClass.getQualifiedName()); - - JavaResolveResult resolveResult = typeElement.advancedResolve(false); - Assert.assertNotNull(resolveResult.getElement()); - Assert.assertEquals("blarg", ((PsiClass)resolveResult.getElement()).getQualifiedName()); - - JavaResolveResult[] resolveResults = typeElement.multiResolve(false); - Assert.assertEquals(1, resolveResults.length); - Assert.assertNotNull(resolveResults[0].getElement()); - Assert.assertEquals("blarg", ((PsiClass)resolveResults[0].getElement()).getQualifiedName()); - } - - /** - * Test a reference to a smali class from a java class - */ - public void testSmaliReferenceFromJava() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;"); - - PsiReference reference = configureByFileText( - "public class blah extends blarg { }", "blah.java"); - - SmaliClass smaliClass = (SmaliClass)reference.resolve(); - Assert.assertNotNull(smaliClass); - Assert.assertEquals("blarg", smaliClass.getQualifiedName()); - } - - - - @Override - protected Sdk getTestProjectJdk() { - return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/ClassRenameTest.java b/smalidea/src/test/java/org/jf/smalidea/ClassRenameTest.java deleted file mode 100644 index d1c7365b..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/ClassRenameTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.jf.smalidea; - -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.refactoring.MultiFileTestCase; -import com.intellij.refactoring.rename.RenameProcessor; -import org.jetbrains.annotations.NotNull; - -public class ClassRenameTest extends MultiFileTestCase { - @Override - protected String getTestDataPath() { - return "testData"; - } - - @NotNull - @Override - protected String getTestRoot() { - return "/classRename/"; - } - - public void testBasicNoPackage() { - doTest("blah", "blah2"); - } - - public void testBasicWithPackage() { - doTest("my.blah", "blah2"); - } - - private void doTest(@NotNull final String oldQualifiedName, @NotNull final String newName) { - doTest(new PerformAction() { - @Override - public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception { - doRename(oldQualifiedName, newName); - } - }); - } - - private void doRename(String oldQualifiedName, String newName) throws Exception { - PsiClass testClass = myJavaFacade.findClass(oldQualifiedName, GlobalSearchScope.allScope(getProject())); - - RenameProcessor processor = new RenameProcessor(getProject(), testClass, newName, false, false); - processor.run(); - - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - FileDocumentManager.getInstance().saveAllDocuments(); - } - -} diff --git a/smalidea/src/test/java/org/jf/smalidea/FieldReferenceTest.java b/smalidea/src/test/java/org/jf/smalidea/FieldReferenceTest.java deleted file mode 100644 index 78360d8b..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/FieldReferenceTest.java +++ /dev/null @@ -1,127 +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; - -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiReference; -import com.intellij.testFramework.ResolveTestCase; -import org.jf.smalidea.psi.impl.SmaliFieldReference; -import org.junit.Assert; - -public class FieldReferenceTest extends ResolveTestCase { - /** - * Test a reference to a java field from a smali class - */ - public void testJavaReferenceFromSmali() throws Exception { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public blah()V\n" + - " .locals 1\n" + - " sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;\n" + - " return-void\n" + - ".end method"; - - SmaliFieldReference fieldReference = (SmaliFieldReference)configureByFileText(text, "blah.smali"); - - Assert.assertNotNull(fieldReference); - Assert.assertEquals("out", fieldReference.getName()); - Assert.assertNotNull(fieldReference.getFieldType()); - Assert.assertEquals("java.io.PrintStream", fieldReference.getFieldType().getType().getCanonicalText()); - - PsiField resolvedField = fieldReference.resolve(); - Assert.assertNotNull(resolvedField); - Assert.assertEquals("out", resolvedField.getName()); - Assert.assertNotNull(resolvedField.getContainingClass()); - Assert.assertEquals("java.lang.System", resolvedField.getContainingClass().getQualifiedName()); - Assert.assertEquals("java.io.PrintStream", resolvedField.getType().getCanonicalText()); - } - - /** - * Test a reference to a smali field from a smali class - */ - public void testSmaliReferenceFromSmali() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;" + - ".field public static blort:I"); - - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public blah()V\n" + - " .locals 1\n" + - " sget v0, Lblarg;->blort:I\n" + - " return-void\n" + - ".end method"; - - SmaliFieldReference fieldReference = (SmaliFieldReference)configureByFileText(text, "blah.smali"); - - Assert.assertNotNull(fieldReference); - Assert.assertEquals("blort", fieldReference.getName()); - Assert.assertNotNull(fieldReference.getFieldType()); - Assert.assertEquals("int", fieldReference.getFieldType().getType().getCanonicalText()); - - PsiField resolvedField = fieldReference.resolve(); - Assert.assertNotNull(resolvedField); - Assert.assertEquals("blort", resolvedField.getName()); - Assert.assertNotNull(resolvedField.getContainingClass()); - Assert.assertEquals("blarg", resolvedField.getContainingClass().getQualifiedName()); - Assert.assertEquals("int", resolvedField.getType().getCanonicalText()); - } - - /** - * Test a reference to a smali field from a java class - */ - public void testSmaliReferenceFromJava() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;" + - ".field public static blort:I"); - - String text = "public class blah { public static void something() {" + - "blarg.blort = 10;" + - "}}"; - - PsiReference fieldReference = configureByFileText(text, "blah.java"); - - Assert.assertNotNull(fieldReference); - - PsiField resolvedField = (PsiField)fieldReference.resolve(); - Assert.assertNotNull(resolvedField); - Assert.assertEquals("blort", resolvedField.getName()); - Assert.assertNotNull(resolvedField.getContainingClass()); - Assert.assertEquals("blarg", resolvedField.getContainingClass().getQualifiedName()); - Assert.assertEquals("int", resolvedField.getType().getCanonicalText()); - } - - @Override - protected Sdk getTestProjectJdk() { - return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/FieldRenameTest.java b/smalidea/src/test/java/org/jf/smalidea/FieldRenameTest.java deleted file mode 100644 index 4edab84c..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/FieldRenameTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.jf.smalidea; - -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiField; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.refactoring.MultiFileTestCase; -import com.intellij.refactoring.rename.RenameProcessor; -import org.jetbrains.annotations.NotNull; - -public class FieldRenameTest extends MultiFileTestCase { - @Override - protected String getTestDataPath() { - return "testData"; - } - - @NotNull - @Override - protected String getTestRoot() { - return "/fieldRename/"; - } - - public void testFieldRename() { - doTest("blah", "blah", "blort"); - } - - private void doTest(@NotNull final String containingClass, @NotNull final String oldFieldName, - @NotNull final String newFieldName) { - doTest(new PerformAction() { - @Override - public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception { - doRename(containingClass, oldFieldName, newFieldName); - } - }); - } - - private void doRename(String containingClass, String oldFieldName, String newFieldName) throws Exception { - PsiClass testClass = myJavaFacade.findClass(containingClass, GlobalSearchScope.allScope(getProject())); - - PsiField field = testClass.findFieldByName(oldFieldName, false); - - RenameProcessor processor = new RenameProcessor(getProject(), field, newFieldName, false, false); - processor.run(); - - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - FileDocumentManager.getInstance().saveAllDocuments(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/LightCodeInsightParsingTestCase.java b/smalidea/src/test/java/org/jf/smalidea/LightCodeInsightParsingTestCase.java deleted file mode 100644 index 290021ac..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/LightCodeInsightParsingTestCase.java +++ /dev/null @@ -1,209 +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; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileEditor.impl.LoadTextUtil; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.psi.*; -import com.intellij.psi.impl.DebugUtil; -import com.intellij.psi.impl.PsiFileFactoryImpl; -import com.intellij.psi.impl.source.PsiFileImpl; -import com.intellij.psi.stubs.SerializationManagerImpl; -import com.intellij.psi.stubs.SerializerNotFoundException; -import com.intellij.psi.stubs.StubTree; -import com.intellij.testFramework.LightVirtualFile; -import com.intellij.testFramework.TestDataFile; -import com.intellij.testFramework.UsefulTestCase; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.util.Set; - -/** - * A test case for parsing tests. - * - * This was originally based on com.intellij.testFramework.ParsingTestCase, but was modified - * to use the LightCodeInsightFixtureTestCase base class, which provides more functionality - */ -public abstract class LightCodeInsightParsingTestCase extends LightCodeInsightFixtureTestCase { - protected final String myFilePrefix = ""; - protected final String myFileExt; - @NonNls protected final String myFullDataPath; - protected final Language myLanguage; - - protected PsiFile myFile; - - public LightCodeInsightParsingTestCase(@NonNls @NotNull String dataPath, @NotNull String fileExt, - @NotNull Language language) { - myLanguage = language; - myFullDataPath = getTestDataPath() + "/" + dataPath; - myFileExt = fileExt; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - myFile = null; - } - - protected boolean includeRanges() { - return false; - } - - protected boolean skipSpaces() { - return false; - } - - protected boolean checkAllPsiRoots() { - return true; - } - - protected void doTest(boolean checkResult) { - String name = getTestName(false); - try { - String text = loadFile(name + "." + myFileExt); - PsiFile f = createPsiFile(name, text); - - if (f instanceof PsiFileImpl) { - // Also want to test stub serialization/deserialization - StubTree stubTree = ((PsiFileImpl)f).calcStubTree(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SerializationManagerImpl.getInstanceEx().serialize(stubTree.getRoot(), baos); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - SerializationManagerImpl.getInstanceEx().deserialize(bais); - } - - ensureParsed(f); - assertEquals("light virtual file text mismatch", text, - ((LightVirtualFile)f.getVirtualFile()).getContent().toString()); - assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(f.getVirtualFile())); - assertEquals("doc text mismatch", text, f.getViewProvider().getDocument().getText()); - assertEquals("psi text mismatch", text, f.getText()); - if (checkResult){ - checkResult(name, f); - } - else{ - toParseTreeText(f, skipSpaces(), includeRanges()); - } - } - catch (IOException e) { - throw new RuntimeException(e); - } catch (SerializerNotFoundException e) { - throw new RuntimeException(e); - } - } - - protected void doTest(String suffix) throws IOException { - String name = getTestName(false); - String text = loadFile(name + "." + myFileExt); - myFile = createPsiFile(name, text); - ensureParsed(myFile); - assertEquals(text, myFile.getText()); - checkResult(name + suffix, myFile); - } - - protected void doCodeTest(String code) throws IOException { - String name = getTestName(false); - myFile = createPsiFile("a", code); - ensureParsed(myFile); - assertEquals(code, myFile.getText()); - checkResult(myFilePrefix + name, myFile); - } - - protected PsiFile createPsiFile(String name, String text) { - return createFile(name + "." + myFileExt, text); - } - - protected PsiFile createFile(@NonNls String name, String text) { - LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text); - virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET); - return createFile(virtualFile); - } - - protected PsiFile createFile(LightVirtualFile virtualFile) { - return ((PsiFileFactoryImpl)PsiFileFactory.getInstance(getProject())).trySetupPsiForFile( - virtualFile, myLanguage, true, false); - } - - protected void checkResult(@NonNls @TestDataFile String targetDataName, final PsiFile file) throws IOException { - doCheckResult(myFullDataPath, file, checkAllPsiRoots(), targetDataName, skipSpaces(), includeRanges()); - } - - public static void doCheckResult(String myFullDataPath, - PsiFile file, - boolean checkAllPsiRoots, - String targetDataName, - boolean skipSpaces, - boolean printRanges) throws IOException { - FileViewProvider provider = file.getViewProvider(); - Set languages = provider.getLanguages(); - - if (!checkAllPsiRoots || languages.size() == 1) { - doCheckResult(myFullDataPath, targetDataName + ".txt", toParseTreeText(file, skipSpaces, printRanges).trim()); - return; - } - - for (Language language : languages) { - PsiFile root = provider.getPsi(language); - String expectedName = targetDataName + "." + language.getID() + ".txt"; - doCheckResult(myFullDataPath, expectedName, toParseTreeText(root, skipSpaces, printRanges).trim()); - } - } - - protected void checkResult(@TestDataFile @NonNls String targetDataName, final String text) throws IOException { - doCheckResult(myFullDataPath, targetDataName, text); - } - - public static void doCheckResult(String fullPath, String targetDataName, String text) throws IOException { - String expectedFileName = fullPath + File.separatorChar + targetDataName; - UsefulTestCase.assertSameLinesWithFile(expectedFileName, text); - } - - protected static String toParseTreeText(final PsiElement file, boolean skipSpaces, boolean printRanges) { - return DebugUtil.psiToString(file, skipSpaces, printRanges); - } - - protected String loadFile(@NonNls @TestDataFile String name) throws IOException { - return doLoadFile(myFullDataPath, name); - } - - private static String doLoadFile(String myFullDataPath, String name) throws IOException { - return FileUtil.loadFile(new File(myFullDataPath, name), CharsetToolkit.UTF8, true).trim(); - } - - public static void ensureParsed(PsiFile file) { - file.accept(new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - element.acceptChildren(this); - } - }); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/MethodReferenceTest.java b/smalidea/src/test/java/org/jf/smalidea/MethodReferenceTest.java deleted file mode 100644 index 1de65983..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/MethodReferenceTest.java +++ /dev/null @@ -1,143 +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.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiReference; -import com.intellij.testFramework.ResolveTestCase; -import org.jf.smalidea.psi.impl.SmaliMethodReference; -import org.junit.Assert; - -public class MethodReferenceTest extends ResolveTestCase { - /** - * Test a reference to a java method from a smali class - */ - public void testJavaReferenceFromSmali() throws Exception { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public blah()V\n" + - " .locals 1\n" + - - " invoke-static {}, Ljava/lang/System;->nanoTime()J\n" + - " return-void\n" + - ".end method"; - - SmaliMethodReference methodReference = (SmaliMethodReference)configureByFileText(text, "blah.smali"); - - Assert.assertNotNull(methodReference); - Assert.assertEquals("nanoTime", methodReference.getName()); - - PsiMethod resolvedMethod = (PsiMethod)methodReference.resolve(); - Assert.assertNotNull(resolvedMethod); - Assert.assertEquals("nanoTime", resolvedMethod.getName()); - Assert.assertNotNull(resolvedMethod.getContainingClass()); - Assert.assertEquals("java.lang.System", resolvedMethod.getContainingClass().getQualifiedName()); - Assert.assertEquals(0, resolvedMethod.getParameterList().getParametersCount()); - Assert.assertNotNull(resolvedMethod.getReturnType()); - Assert.assertEquals("long", resolvedMethod.getReturnType().getCanonicalText()); - } - - /** - * Test a reference to a smali method from a smali class - */ - public void testSmaliReferenceFromSmali() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;" + - ".method public static blort(ILjava/lang/String;)V\n" + - " .locals 0\n" + - " return-void\n" + - ".end method\n"); - - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public blah2()V\n" + - " .locals 0\n" + - " invoke-static {}, Lblarg;->blort(ILjava/lang/String;)V\n" + - " return-void\n" + - ".end method"; - - SmaliMethodReference methodReference = (SmaliMethodReference)configureByFileText(text, "blah.smali"); - - Assert.assertNotNull(methodReference); - Assert.assertEquals("blort", methodReference.getName()); - - PsiMethod resolvedMethod = (PsiMethod)methodReference.resolve(); - Assert.assertNotNull(resolvedMethod); - Assert.assertEquals("blort", resolvedMethod.getName()); - Assert.assertNotNull(resolvedMethod.getContainingClass()); - Assert.assertEquals("blarg", resolvedMethod.getContainingClass().getQualifiedName()); - Assert.assertEquals(2, resolvedMethod.getParameterList().getParametersCount()); - Assert.assertEquals("int", resolvedMethod.getParameterList().getParameters()[0].getType().getCanonicalText()); - Assert.assertEquals("java.lang.String", - resolvedMethod.getParameterList().getParameters()[1].getType().getCanonicalText()); - Assert.assertNotNull(resolvedMethod.getReturnType()); - Assert.assertEquals("void", resolvedMethod.getReturnType().getCanonicalText()); - } - - /** - * Test a reference to a smali method from a java class - */ - public void testSmaliReferenceFromJava() throws Exception { - createFile("blarg.smali", ".class public Lblarg; .super Ljava/lang/Object;" + - ".method public static blort(ILjava/lang/String;)V\n" + - " .locals 0\n" + - " return-void\n" + - ".end method\n"); - - - String text = "public class blah { public static void something() {" + - "blarg.blort(10, \"bob\");" + - "}}"; - - PsiReference methodReference = configureByFileText(text, "blah.java"); - - Assert.assertNotNull(methodReference); - - PsiMethod resolvedMethod = (PsiMethod)methodReference.resolve(); - Assert.assertNotNull(resolvedMethod); - Assert.assertEquals("blort", resolvedMethod.getName()); - Assert.assertNotNull(resolvedMethod.getContainingClass()); - Assert.assertEquals("blarg", resolvedMethod.getContainingClass().getQualifiedName()); - Assert.assertEquals(2, resolvedMethod.getParameterList().getParametersCount()); - Assert.assertEquals("int", resolvedMethod.getParameterList().getParameters()[0].getType().getCanonicalText()); - Assert.assertEquals("java.lang.String", - resolvedMethod.getParameterList().getParameters()[1].getType().getCanonicalText()); - Assert.assertNotNull(resolvedMethod.getReturnType()); - Assert.assertEquals("void", resolvedMethod.getReturnType().getCanonicalText()); - } - - @Override - protected Sdk getTestProjectJdk() { - return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/MethodRenameTest.java b/smalidea/src/test/java/org/jf/smalidea/MethodRenameTest.java deleted file mode 100644 index 29cf4d36..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/MethodRenameTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.jf.smalidea; - -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.refactoring.MultiFileTestCase; -import com.intellij.refactoring.rename.RenameProcessor; -import org.jetbrains.annotations.NotNull; - -public class MethodRenameTest extends MultiFileTestCase { - @Override - protected String getTestDataPath() { - return "testData"; - } - - @NotNull - @Override - protected String getTestRoot() { - return "/methodRename/"; - } - - public void testMethodRename() { - doTest("blah", "blah", "blort"); - } - - private void doTest(@NotNull final String containingClass, @NotNull final String oldMethodName, - @NotNull final String newMethodName) { - doTest(new PerformAction() { - @Override - public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception { - doRename(containingClass, oldMethodName, newMethodName); - } - }); - } - - private void doRename(String containingClass, String oldMethodName, String newMethodName) throws Exception { - PsiClass testClass = myJavaFacade.findClass(containingClass, GlobalSearchScope.allScope(getProject())); - - PsiMethod method = testClass.findMethodsByName(oldMethodName, false)[0]; - - RenameProcessor processor = new RenameProcessor(getProject(), method, newMethodName, false, false); - processor.run(); - - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - FileDocumentManager.getInstance().saveAllDocuments(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/ParserTest.java b/smalidea/src/test/java/org/jf/smalidea/ParserTest.java deleted file mode 100644 index 0504bfe3..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/ParserTest.java +++ /dev/null @@ -1,67 +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; - -public class ParserTest extends LightCodeInsightParsingTestCase { - public ParserTest() { - super("", "smalidea", SmaliLanguage.INSTANCE); - } - - @Override - protected String getTestDataPath() { - return "testData"; - } - - public void testEmpty() throws Exception { doTest(true); } - public void testFieldAnnotations() throws Exception { doTest(true); } - public void testInvalidAnnotation() throws Exception { doTest(true); } - public void testInvalidClassDirective() throws Exception { doTest(true); } - public void testInvalidClassDirective2() throws Exception { doTest(true); } - public void testInvalidClassDirective3() throws Exception { doTest(true); } - public void testInvalidEnumLiteral() throws Exception { doTest(true); } - public void testInvalidField() throws Exception { doTest(true); } - public void testInvalidField2() throws Exception { doTest(true); } - public void testInvalidField3() throws Exception { doTest(true); } - public void testInvalidField4() throws Exception { doTest(true); } - public void testInvalidInstruction() throws Exception { doTest(true); } - public void testInvalidLocal() throws Exception { doTest(true);} - public void testParamListInvalidParameter() throws Exception { doTest(true); } - public void testSuperClassInvalidSyntax() throws Exception { doTest(true); } - public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); } - public void testInvalidMethodReference() throws Exception { doTest(true); } - public void testInvalidParameter() throws Exception { doTest(true); } - public void testInvalidMethod() throws Exception { doTest(true); } - public void testInvalidMethod2() throws Exception { doTest(true); } - public void testInvalidMethod3() throws Exception { doTest(true); } - public void testInvalidMethod4() throws Exception { doTest(true); } - public void testMissingDotDot() throws Exception { doTest(true); } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliAnnotationTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliAnnotationTest.java deleted file mode 100644 index 3cd863f9..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliAnnotationTest.java +++ /dev/null @@ -1,273 +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.psi.*; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliLiteral; -import org.jf.smalidea.psi.impl.SmaliMethod; -import org.junit.Assert; - -public class SmaliAnnotationTest extends LightCodeInsightFixtureTestCase { - // TODO: test default values - - public void testClassAnnotation() { - myFixture.addFileToProject("my/TestAnnotation.smali", - ".class public interface abstract annotation Lmy/TestAnnotation;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract testBooleanValue()Z\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringArrayValue()[Ljava/lang/String;\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringValue()Ljava/lang/String;\n" + - ".end method"); - - myFixture.addFileToProject("my/TestAnnotation2.smali", - ".class public interface abstract annotation Lmy/TestAnnotation2;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - "\n" + - ".annotation runtime Lmy/TestAnnotation;\n" + - " testBooleanValue = true\n" + - " testStringValue = \"blah\"\n" + - " testStringArrayValue = {\n" + - " \"blah1\",\n" + - " \"blah2\"\n" + - " }\n" + - ".end annotation\n" + - "\n" + - ".annotation runtime Lmy/TestAnnotation2;\n" + - ".end annotation"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - doTest(smaliClass); - } - - public void testFieldAnnotation() { - myFixture.addFileToProject("my/TestAnnotation.smali", - ".class public interface abstract annotation Lmy/TestAnnotation;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract testBooleanValue()Z\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringArrayValue()[Ljava/lang/String;\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringValue()Ljava/lang/String;\n" + - ".end method"); - - myFixture.addFileToProject("my/TestAnnotation2.smali", - ".class public interface abstract annotation Lmy/TestAnnotation2;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - "\n" + - ".field public myField:I\n" + - " .annotation runtime Lmy/TestAnnotation;\n" + - " testBooleanValue = true\n" + - " testStringValue = \"blah\"\n" + - " testStringArrayValue = {\n" + - " \"blah1\",\n" + - " \"blah2\"\n" + - " }\n" + - " .end annotation\n" + - " .annotation runtime Lmy/TestAnnotation2;\n" + - " .end annotation\n" + - ".end field"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - PsiField field = smaliClass.findFieldByName("myField", false); - doTest((PsiAnnotationOwner)field); - } - - public void testMethodAnnotation() { - myFixture.addFileToProject("my/TestAnnotation.smali", - ".class public interface abstract annotation Lmy/TestAnnotation;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract testBooleanValue()Z\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringArrayValue()[Ljava/lang/String;\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringValue()Ljava/lang/String;\n" + - ".end method"); - - myFixture.addFileToProject("my/TestAnnotation2.smali", - ".class public interface abstract annotation Lmy/TestAnnotation2;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - "\n" + - ".method public myMethod()V\n" + - " .annotation runtime Lmy/TestAnnotation;\n" + - " testBooleanValue = true\n" + - " testStringValue = \"blah\"\n" + - " testStringArrayValue = {\n" + - " \"blah1\",\n" + - " \"blah2\"\n" + - " }\n" + - " .end annotation\n" + - " .annotation runtime Lmy/TestAnnotation2;\n" + - " .end annotation\n" + - ".end method"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - SmaliMethod method = smaliClass.getMethods()[0]; - doTest(method); - } - - public void doTest(PsiAnnotationOwner annotationOwner) { - Assert.assertEquals(2, annotationOwner.getAnnotations().length); - - Assert.assertEquals("my.TestAnnotation", annotationOwner.getAnnotations()[0].getQualifiedName()); - PsiJavaCodeReferenceElement annotationNameRef = annotationOwner.getAnnotations()[0].getNameReferenceElement(); - Assert.assertNotNull(annotationNameRef); - SmaliClass smaliAnnotationClass = (SmaliClass)annotationNameRef.resolve(); - Assert.assertNotNull(smaliAnnotationClass); - Assert.assertEquals("my.TestAnnotation", smaliAnnotationClass.getQualifiedName()); - - Assert.assertEquals("my.TestAnnotation2", annotationOwner.getAnnotations()[1].getQualifiedName()); - annotationNameRef = annotationOwner.getAnnotations()[1].getNameReferenceElement(); - Assert.assertNotNull(annotationNameRef); - smaliAnnotationClass = (SmaliClass)annotationNameRef.resolve(); - Assert.assertNotNull(smaliAnnotationClass); - Assert.assertEquals("my.TestAnnotation2", smaliAnnotationClass.getQualifiedName()); - - PsiAnnotation smaliAnnotation = annotationOwner.findAnnotation("my.TestAnnotation"); - Assert.assertNotNull(smaliAnnotation); - Assert.assertEquals("my.TestAnnotation", smaliAnnotation.getQualifiedName()); - PsiAnnotationOwner owner = smaliAnnotation.getOwner(); - Assert.assertNotNull(owner); - Assert.assertSame(annotationOwner, owner); - annotationNameRef = smaliAnnotation.getNameReferenceElement(); - Assert.assertNotNull(annotationNameRef); - smaliAnnotationClass = (SmaliClass)annotationNameRef.resolve(); - Assert.assertNotNull(smaliAnnotationClass); - Assert.assertEquals("my.TestAnnotation", smaliAnnotationClass.getQualifiedName()); - - PsiAnnotationParameterList parameterList = smaliAnnotation.getParameterList(); - Assert.assertNotNull(parameterList); - Assert.assertEquals(3, parameterList.getAttributes().length); - Assert.assertEquals("testBooleanValue", parameterList.getAttributes()[0].getName()); - PsiAnnotationMemberValue value = parameterList.getAttributes()[0].getValue(); - Assert.assertNotNull(value); - // TODO: test the values rather than the text - Assert.assertEquals("true", value.getText()); - Assert.assertEquals("testStringValue", parameterList.getAttributes()[1].getName()); - value = parameterList.getAttributes()[1].getValue(); - Assert.assertNotNull(value); - Assert.assertEquals("\"blah\"", value.getText()); - Assert.assertEquals("testStringArrayValue", parameterList.getAttributes()[2].getName()); - value = parameterList.getAttributes()[2].getValue(); - Assert.assertNotNull(value); - // TODO: test the individual values, once the array literal stuff is implemented - - value = smaliAnnotation.findAttributeValue("testBooleanValue"); - Assert.assertNotNull(value); - Assert.assertEquals("true", value.getText()); - - value = smaliAnnotation.findAttributeValue("testStringValue"); - Assert.assertNotNull(value); - Assert.assertEquals("\"blah\"", value.getText()); - - value = smaliAnnotation.findAttributeValue("testStringArrayValue"); - Assert.assertNotNull(value); - - // TODO: test findAttributeValue vs findDeclaredAttributeValue for default values - - smaliAnnotation = annotationOwner.findAnnotation("my.TestAnnotation2"); - Assert.assertNotNull(smaliAnnotation); - Assert.assertEquals("my.TestAnnotation2", smaliAnnotation.getQualifiedName()); - owner = smaliAnnotation.getOwner(); - Assert.assertNotNull(owner); - Assert.assertSame(annotationOwner, owner); - annotationNameRef = smaliAnnotation.getNameReferenceElement(); - Assert.assertNotNull(annotationNameRef); - smaliAnnotationClass = (SmaliClass)annotationNameRef.resolve(); - Assert.assertNotNull(smaliAnnotationClass); - Assert.assertEquals("my.TestAnnotation2", smaliAnnotationClass.getQualifiedName()); - - parameterList = smaliAnnotation.getParameterList(); - Assert.assertNotNull(parameterList); - Assert.assertEquals(0, parameterList.getAttributes().length); - } - - public void testDefaultValue() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("AnnotationWithDefaultValue.smali", "" + - ".class public abstract interface annotation LAnnotationWithValues;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract intValue()I\n" + - ".end method\n" + - "\n" + - ".annotation system Ldalvik/annotation/AnnotationDefault;\n" + - " value = .subannotation LAnnotationWithValues;\n" + - " intValue = 4\n" + - " .end subannotation\n" + - ".end annotation\n" + - "\n"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertNotNull(smaliClass); - SmaliMethod method = smaliClass.getMethods()[0]; - Assert.assertEquals("intValue", method.getName()); - - PsiAnnotationMemberValue defaultValue = method.getDefaultValue(); - Assert.assertTrue(defaultValue instanceof SmaliLiteral); - Assert.assertEquals(4, ((SmaliLiteral)defaultValue).getIntegralValue()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliClassModifierListTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliClassModifierListTest.java deleted file mode 100644 index a841d0f1..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliClassModifierListTest.java +++ /dev/null @@ -1,194 +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.application.ApplicationManager; -import com.intellij.psi.PsiModifierListOwner; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.dexlib2.AccessFlags; -import org.jf.smalidea.psi.impl.SmaliAnnotation; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliModifierList; -import org.junit.Assert; - -public class SmaliClassModifierListTest extends LightCodeInsightFixtureTestCase { - public void testAllClassAccessFlags() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public final interface abstract synthetic enum annotation Lmy/pkg/blah; " + - ".super Ljava/lang/Object;"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliModifierList modifierList = smaliClass.getModifierList(); - - Assert.assertEquals(AccessFlags.PUBLIC.getValue() | - AccessFlags.FINAL.getValue() | - AccessFlags.INTERFACE.getValue() | - AccessFlags.ABSTRACT.getValue() | - AccessFlags.SYNTHETIC.getValue() | - AccessFlags.ENUM.getValue() | - AccessFlags.ANNOTATION.getValue(), - modifierList.getAccessFlags()); - - Assert.assertTrue(modifierList.hasModifierProperty("public")); - Assert.assertTrue(modifierList.hasModifierProperty("final")); - Assert.assertTrue(modifierList.hasModifierProperty("interface")); - Assert.assertTrue(modifierList.hasModifierProperty("abstract")); - Assert.assertTrue(modifierList.hasModifierProperty("synthetic")); - Assert.assertTrue(modifierList.hasModifierProperty("enum")); - Assert.assertTrue(modifierList.hasModifierProperty("annotation")); - - Assert.assertTrue(modifierList.hasExplicitModifier("public")); - Assert.assertTrue(modifierList.hasExplicitModifier("final")); - Assert.assertTrue(modifierList.hasExplicitModifier("interface")); - Assert.assertTrue(modifierList.hasExplicitModifier("abstract")); - Assert.assertTrue(modifierList.hasExplicitModifier("synthetic")); - Assert.assertTrue(modifierList.hasExplicitModifier("enum")); - Assert.assertTrue(modifierList.hasExplicitModifier("annotation")); - } - - public void testNoClassAccessFlags() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class Lmy/pkg/blah; " + - ".super Ljava/lang/Object;"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliModifierList modifierList = smaliClass.getModifierList(); - - Assert.assertEquals(0, modifierList.getAccessFlags()); - - Assert.assertFalse(modifierList.hasModifierProperty("public")); - Assert.assertFalse(modifierList.hasModifierProperty("final")); - Assert.assertFalse(modifierList.hasModifierProperty("interface")); - Assert.assertFalse(modifierList.hasModifierProperty("abstract")); - Assert.assertFalse(modifierList.hasModifierProperty("synthetic")); - Assert.assertFalse(modifierList.hasModifierProperty("enum")); - Assert.assertFalse(modifierList.hasModifierProperty("annotation")); - - Assert.assertFalse(modifierList.hasExplicitModifier("public")); - Assert.assertFalse(modifierList.hasExplicitModifier("final")); - Assert.assertFalse(modifierList.hasExplicitModifier("interface")); - Assert.assertFalse(modifierList.hasExplicitModifier("abstract")); - Assert.assertFalse(modifierList.hasExplicitModifier("synthetic")); - Assert.assertFalse(modifierList.hasExplicitModifier("enum")); - Assert.assertFalse(modifierList.hasExplicitModifier("annotation")); - } - - public void testAddClassAccessFlag() { - final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;"); - myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); - - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override public void run() { - file.getPsiClass().getModifierList().setModifierProperty("final", true); - } - }); - - myFixture.checkResult( - ".class public final Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;"); - } - - public void testRemoveClassAccessFlag() { - final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public final Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;"); - myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); - - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override public void run() { - file.getPsiClass().getModifierList().setModifierProperty("final", false); - } - }); - - myFixture.checkResult( - ".class public Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;"); - } - - public void testBasicAnnotation() { - final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public final Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;\n" + - ".annotation Lmy/pkg/anno; .end annotation"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliModifierList modifierList = smaliClass.getModifierList(); - - SmaliAnnotation[] annotations = modifierList.getAnnotations(); - Assert.assertEquals(1, annotations.length); - - Assert.assertEquals("my.pkg.anno", annotations[0].getQualifiedName()); - - SmaliAnnotation[] applicableAnnotations = modifierList.getApplicableAnnotations(); - Assert.assertEquals(1, applicableAnnotations.length); - Assert.assertEquals(annotations[0], applicableAnnotations[0]); - } - - public void testNoAnnotation() { - final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public final Lmy/pkg/blah;\n" + - ".super Ljava/lang/Object;"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliModifierList modifierList = smaliClass.getModifierList(); - - // Ensures that the parent of the modifier list is a PsiModifierListOwner - // e.g. for code like JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation, - // which assumes the parent is a PsiModifierListOwner - Assert.assertTrue(modifierList.getParent() instanceof PsiModifierListOwner); - - Assert.assertEquals(0, modifierList.getAnnotations().length); - Assert.assertEquals(0, modifierList.getApplicableAnnotations().length); - } - - public void testFindAnnotation() { - final SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public final Lmy/pkg/blah;\n" + - ".annotation Lanno; .end annotation\n" + - ".super Ljava/lang/Object;\n" + - ".annotation Lmy/pkg/anno; .end annotation\n" + - ".annotation Lmy/pkg/anno2; .end annotation\n" + - ".annotation Lmy/pkg/anno3; .end annotation\n"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliModifierList modifierList = smaliClass.getModifierList(); - - SmaliAnnotation smaliAnnotation = modifierList.findAnnotation("my.pkg.anno2"); - Assert.assertNotNull(smaliAnnotation); - Assert.assertEquals("my.pkg.anno2", smaliAnnotation.getQualifiedName()); - } - - // TODO: test modifierList.addAnnotation once implemented -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliClassTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliClassTest.java deleted file mode 100644 index ba18b662..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliClassTest.java +++ /dev/null @@ -1,168 +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.module.Module; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.LanguageLevelModuleExtension; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassType; -import com.intellij.psi.PsiElementFactory; -import com.intellij.testFramework.LightProjectDescriptor; -import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.junit.Assert; - -public class SmaliClassTest extends LightCodeInsightFixtureTestCase { - public void testName() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - Assert.assertEquals("my.pkg", smaliClass.getPackageName()); - Assert.assertEquals("blah", smaliClass.getName()); - } - - public void testEmptyPackageName() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lblah; .super Ljava/lang/Object;"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("blah", smaliClass.getQualifiedName()); - Assert.assertEquals("", smaliClass.getPackageName()); - } - - public void testGetSuperclass() { - myFixture.addFileToProject("base.smali", - ".class public interface Lbase; .super Ljava/lang/Object;"); - - myFixture.addFileToProject("iface.smali", - ".class public interface Liface; .super Ljava/lang/Object;"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("blah.smali", - ".class public Lblah; .super Lbase; .implements Liface;"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("blah", smaliClass.getQualifiedName()); - PsiClass superClass = smaliClass.getSuperClass(); - Assert.assertNotNull(superClass); - Assert.assertEquals("base", smaliClass.getSuperClass().getQualifiedName()); - - Assert.assertEquals(2, smaliClass.getSupers().length); - Assert.assertEquals("base", smaliClass.getSupers()[0].getQualifiedName()); - Assert.assertEquals("iface", smaliClass.getSupers()[1].getQualifiedName()); - - Assert.assertEquals(2, smaliClass.getSuperTypes().length); - Assert.assertEquals("base", smaliClass.getSuperTypes()[0].getCanonicalText()); - Assert.assertEquals("iface", smaliClass.getSuperTypes()[1].getCanonicalText()); - - Assert.assertEquals(1, smaliClass.getInterfaces().length); - Assert.assertEquals("iface", smaliClass.getInterfaces()[0].getQualifiedName()); - } - - public void testGetSuperclassForInterface() { - myFixture.addFileToProject("iface.smali", - ".class public interface Liface; .super Ljava/lang/Object;"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("blah.smali", - ".class public interface Lblah; .super Ljava/lang/Object; .implements Liface;"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("blah", smaliClass.getQualifiedName()); - PsiClass superClass = smaliClass.getSuperClass(); - Assert.assertNotNull(superClass); - Assert.assertEquals("java.lang.Object", smaliClass.getSuperClass().getQualifiedName()); - - Assert.assertEquals(2, smaliClass.getSupers().length); - Assert.assertEquals("java.lang.Object", smaliClass.getSupers()[0].getQualifiedName()); - Assert.assertEquals("iface", smaliClass.getSupers()[1].getQualifiedName()); - - Assert.assertEquals(1, smaliClass.getSuperTypes().length); - Assert.assertEquals("iface", smaliClass.getSuperTypes()[0].getCanonicalText()); - - Assert.assertEquals(1, smaliClass.getInterfaces().length); - Assert.assertEquals("iface", smaliClass.getInterfaces()[0].getQualifiedName()); - } - - public void testIsInheritor() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("blah.smali", - ".class public Lblah; .super Ljava/lang/Exception;"); - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("blah", smaliClass.getQualifiedName()); - - PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); - PsiClassType throwableType = factory.createTypeByFQClassName("java.lang.Throwable", file.getResolveScope()); - PsiClass throwableClass = throwableType.resolve(); - Assert.assertNotNull(throwableClass); - - PsiClassType exceptionType = factory.createTypeByFQClassName("java.lang.Exception", file.getResolveScope()); - PsiClass exceptionClass = exceptionType.resolve(); - Assert.assertNotNull(exceptionClass); - - PsiClassType objectType = factory.createTypeByFQClassName("java.lang.Object", file.getResolveScope()); - PsiClass objectClass = objectType.resolve(); - Assert.assertNotNull(objectClass); - - Assert.assertTrue(smaliClass.isInheritor(exceptionClass, true)); - Assert.assertTrue(smaliClass.isInheritor(throwableClass, true)); - Assert.assertTrue(smaliClass.isInheritor(objectClass, true)); - - Assert.assertTrue(smaliClass.isInheritorDeep(exceptionClass, null)); - Assert.assertTrue(smaliClass.isInheritorDeep(throwableClass, null)); - Assert.assertTrue(smaliClass.isInheritorDeep(objectClass, null)); - - Assert.assertTrue(smaliClass.isInheritor(exceptionClass, false)); - Assert.assertFalse(smaliClass.isInheritor(throwableClass, false)); - Assert.assertFalse(smaliClass.isInheritor(objectClass, false)); - } - - @NotNull @Override protected LightProjectDescriptor getProjectDescriptor() { - return new DefaultLightProjectDescriptor() { - public Sdk getSdk() { - return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); - } - - public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) { - model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_1_6); - } - }; - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliClassTypeElementTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliClassTypeElementTest.java deleted file mode 100644 index 434c959b..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliClassTypeElementTest.java +++ /dev/null @@ -1,172 +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.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliClassType; -import org.jf.smalidea.psi.impl.SmaliClassTypeElement; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.junit.Assert; - -public class SmaliClassTypeElementTest extends LightCodeInsightFixtureTestCase { - public void testGetType() { - myFixture.addFileToProject("my/blarg.smali", - ".class public Lmy/blarg; " + - ".super Ljava/lang/Object;"); - - String text = ".class public Lmy/pkg/blah; " + - ".super Lmy/blarg;"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - SmaliClassTypeElement typeElement = - (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - SmaliClassType type = typeElement.getType(); - - Assert.assertEquals("blarg", typeElement.getName()); - Assert.assertEquals("my.blarg", typeElement.getCanonicalText()); - Assert.assertEquals("blarg", type.getClassName()); - Assert.assertEquals("my.blarg", type.getCanonicalText()); - - SmaliClass resolvedClass = (SmaliClass)typeElement.resolve(); - Assert.assertNotNull(resolvedClass); - Assert.assertEquals("my.blarg", resolvedClass.getQualifiedName()); - - resolvedClass = (SmaliClass)type.resolve(); - Assert.assertNotNull(resolvedClass); - Assert.assertEquals("my.blarg", resolvedClass.getQualifiedName()); - } - - public void testSimpleInnerClass() { - myFixture.addFileToProject("Outer.java", "" + - "public class Outer {" + - " public static class Inner {" + - " }" + - "}"); - - String text = ".class public Lsmali; " + - ".super LOuter$Inner;"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("smali.smali", text.replace("", "")); - - SmaliClassTypeElement typeElement = - (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - SmaliClassType type = typeElement.getType(); - - Assert.assertEquals("Outer.Inner", typeElement.getQualifiedName()); - Assert.assertEquals("Outer.Inner", type.getCanonicalText()); - } - - public void testInnerClassWithPackage() { - myFixture.addFileToProject("my/Outer.java", "" + - "package my;" + - "public class Outer {" + - " public static class Inner {" + - " }" + - "}"); - - String text = ".class public Lsmali; " + - ".super Lmy/Outer$Inner;"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("smali.smali", text.replace("", "")); - - SmaliClassTypeElement typeElement = - (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - SmaliClassType type = typeElement.getType(); - - Assert.assertEquals("my.Outer.Inner", typeElement.getQualifiedName()); - Assert.assertEquals("my.Outer.Inner", type.getCanonicalText()); - } - - public void testComplexInnerClass() { - myFixture.addFileToProject("my/Outer$blah.java", "" + - "package my;" + - "public class Outer$blah {" + - " public static class Inner {" + - " }" + - " public static class Inner$blah {" + - " }" + - "}"); - - String text = ".class public Lsmali; " + - ".super Lmy/Outer$blah$Inner$blah;"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("smali.smali", text.replace("", "")); - - SmaliClassTypeElement typeElement = - (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - SmaliClassType type = typeElement.getType(); - - Assert.assertEquals("my.Outer$blah.Inner$blah", typeElement.getQualifiedName()); - Assert.assertEquals("my.Outer$blah.Inner$blah", type.getCanonicalText()); - - text = ".class public Lsmali2; " + - ".super Lmy/Outer$blah$Inner;"; - - file = (SmaliFile)myFixture.addFileToProject("smali2.smali", text.replace("", "")); - - typeElement = (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - type = typeElement.getType(); - - Assert.assertEquals("my.Outer$blah.Inner", typeElement.getQualifiedName()); - Assert.assertEquals("my.Outer$blah.Inner", type.getCanonicalText()); - } - - public void testInnerClassTrailingDollar() { - myFixture.addFileToProject("my/Outer$blah.java", "" + - "package my;" + - "public class Outer$ {" + - " public static class Inner$ {" + - " }" + - "}"); - - String text = ".class public Lsmali; " + - ".super Lmy/Outer$$Inner$;"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("smali.smali", text.replace("", "")); - - SmaliClassTypeElement typeElement = - (SmaliClassTypeElement)file.findReferenceAt(text.indexOf("")); - Assert.assertNotNull(typeElement); - SmaliClassType type = typeElement.getType(); - - Assert.assertEquals("my.Outer$.Inner$", typeElement.getQualifiedName()); - Assert.assertEquals("my.Outer$.Inner$", type.getCanonicalText()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliCodeFragmentFactoryTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliCodeFragmentFactoryTest.java deleted file mode 100644 index c61d3e44..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliCodeFragmentFactoryTest.java +++ /dev/null @@ -1,279 +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; - -import com.google.common.collect.Sets; -import com.intellij.codeInsight.CodeInsightTestCase; -import com.intellij.codeInsight.completion.CodeCompletionHandlerBase; -import com.intellij.codeInsight.completion.CompletionType; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.lookup.LookupManager; -import com.intellij.debugger.NoDataException; -import com.intellij.debugger.engine.evaluation.CodeFragmentKind; -import com.intellij.debugger.engine.evaluation.TextWithImportsImpl; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.impl.EditorImpl; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.OpenFileDescriptor; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.JavaCodeFragment; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl; -import org.jetbrains.annotations.NotNull; -import org.jf.smalidea.debugging.SmaliCodeFragmentFactory; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.junit.Assert; - -import java.util.HashSet; -import java.util.List; - -public class SmaliCodeFragmentFactoryTest extends CodeInsightTestCase { - private static final String completionTestClass = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public getRandomParentType(I)I\n" + - " .registers 4\n" + - " .param p1, \"edge\" # I\n" + - "\n" + - " .prologue\n" + - " const/4 v1, 0x2\n" + // 0 - "\n" + - " .line 179\n" + - " if-nez p1, :cond_5\n" + - "\n" + - " move v0, v1\n" + // 2 - "\n" + - " .line 185\n" + - " :goto_4\n" + - " return v0\n" + - "\n" + - " .line 182\n" + - " :cond_5\n" + - " if-ne p1, v1, :cond_f\n" + - "\n" + - " .line 183\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " const/4 v1, 0x3\n" + // 6 - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - "\n" + - " .line 185\n" + - " :cond_f\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - ".end method"; - - public void testCompletion() throws NoDataException { - SmaliFile smaliFile = (SmaliFile)configureByText(SmaliFileType.INSTANCE, completionTestClass); - - PsiElement context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(0); - assertCompletionContains("v", context, new String[] {"v2", "v3"}, new String[] {"v0", "v1", "p0", "p1"}); - assertCompletionContains("p", context, new String[] {"p0", "p1"}, new String[] {"v0", "v1", "v2", "v3"}); - - context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(2); - assertCompletionContains("v", context, new String[] {"v1", "v2", "v3"}, new String[] {"v0", "p0", "p1"}); - assertCompletionContains("p", context, new String[] {"p0", "p1"}, new String[] {"v0", "v1", "v2", "v3"}); - - context = smaliFile.getPsiClass().getMethods()[0].getInstructions().get(6); - assertCompletionContains("v", context, new String[] {"v0", "v1", "v2", "v3"}, new String[] {"p0", "p1"}); - assertCompletionContains("p", context, new String[] {"p0", "p1"}, new String[] {}); - } - - private static final String registerTypeTestText = "" + - ".class public LRegisterTypeTest;\n" + - ".super Ljava/lang/Object;\n" + - "\n" + - "# virtual methods\n" + - ".method public blah()V\n" + - " .registers 6\n" + - "\n" + - " .prologue\n" + - " const/16 v3, 0xa\n" + - "\n" + - " .line 7\n" + - " new-instance v0, Ljava/util/Random;\n" + - "\n" + - " invoke-direct {v0}, Ljava/util/Random;->()V\n" + - "\n" + - " .line 9\n" + - " invoke-virtual {v0, v3}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v1\n" + - "\n" + - " const/4 v2, 0x5\n" + - "\n" + - " if-le v1, v2, :cond_26\n" + - "\n" + - " .line 10\n" + - " new-instance v1, Ljava/security/SecureRandom;\n" + - "\n" + - " invoke-direct {v1}, Ljava/security/SecureRandom;->()V\n" + - "\n" + - " .line 14\n" + - " :goto_13\n" + - " sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;\n" + - "\n" + - " invoke-virtual {v1, v3}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v1\n" + - "\n" + - " invoke-virtual {v2, v1}, Ljava/io/PrintStream;->println(I)V\n" + - "\n" + - " .line 15\n" + - " sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;\n" + - "\n" + - " invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;\n" + - "\n" + - " move-result-object v0\n" + - "\n" + - " invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V\n" + - "\n" + - " .line 16\n" + - " return-void\n" + - "\n" + - " .line 12\n" + - " :cond_26\n" + - " invoke-virtual {p0}, LRegisterTypeTest;->getSerializable()Ljava/io/Serializable;\n" + - "\n" + - " move-result-object v1\n" + - "\n" + - " move-object v4, v1\n" + - "\n" + - " move-object v1, v0\n" + - "\n" + - " move-object v0, v4\n" + - "\n" + - " goto :goto_13\n" + - ".end method\n" + - "\n" + - ".method public getSerializable()Ljava/io/Serializable;\n" + - " .registers 2\n" + - "\n" + - " .prologue\n" + - " .line 19\n" + - " new-instance v0, Ljava/util/Random;\n" + - "\n" + - " invoke-direct {v0}, Ljava/util/Random;->()V\n" + - "\n" + - " return-object v0\n" + - ".end method\n"; - - public void testRegisterType() throws NoDataException { - SmaliFile smaliFile = (SmaliFile)configureByText(SmaliFileType.INSTANCE, - registerTypeTestText.replace("", "")); - - int refOffset = registerTypeTestText.indexOf(""); - - PsiElement context = smaliFile.findElementAt(refOffset); - assertVariableType(context.getParent(), "v1", "java.util.Random"); - assertVariableType(context.getParent(), "v0", "java.io.Serializable"); - } - - public void testUnknownClass() { - String modifiedText = registerTypeTestText.replace("Random", "Rnd"); - SmaliFile smaliFile = (SmaliFile)configureByText(SmaliFileType.INSTANCE, - modifiedText.replace("", "")); - - int refOffset = modifiedText.indexOf(""); - - PsiElement context = smaliFile.findElementAt(refOffset); - assertVariableType(context.getParent(), "v1", "java.lang.Object"); - assertVariableType(context.getParent(), "v0", "java.lang.Object"); - } - - private void assertCompletionContains(String completionText, PsiElement context, String[] expectedItems, - String[] disallowedItems) { - SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory(); - JavaCodeFragment fragment = codeFragmentFactory.createCodeFragment( - new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, completionText), - context, getProject()); - - Editor editor = createEditor(fragment.getVirtualFile()); - editor.getCaretModel().moveToOffset(completionText.length()); - - new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), editor); - List elements = LookupManager.getInstance(getProject()).getActiveLookup().getItems(); - - HashSet expectedSet = Sets.newHashSet(expectedItems); - HashSet disallowedSet = Sets.newHashSet(disallowedItems); - - for (LookupElement element: elements) { - expectedSet.remove(element.toString()); - Assert.assertFalse(disallowedSet.contains(element.toString())); - } - - Assert.assertTrue(expectedSet.size() == 0); - } - - private void assertVariableType(PsiElement context, String variableName, String expectedType) { - SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory(); - JavaCodeFragment fragment = codeFragmentFactory.createCodeFragment( - new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, variableName), - context, getProject()); - - Editor editor = createEditor(fragment.getVirtualFile()); - editor.getCaretModel().moveToOffset(1); - - PsiElement element = fragment.findElementAt(0); - Assert.assertTrue(element.getParent() instanceof PsiReferenceExpressionImpl); - PsiReferenceExpressionImpl reference = (PsiReferenceExpressionImpl)element.getParent(); - Assert.assertEquals(expectedType, reference.getType().getCanonicalText()); - } - - protected Editor createEditor(@NotNull VirtualFile file) { - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - Editor editor = FileEditorManager.getInstance(getProject()).openTextEditor( - new OpenFileDescriptor(getProject(), file, 0), false); - DaemonCodeAnalyzer.getInstance(getProject()).restart(); - - ((EditorImpl)editor).setCaretActive(); - return editor; - } - - @Override - protected Sdk getTestProjectJdk() { - return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliFieldTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliFieldTest.java deleted file mode 100644 index 05e46bc2..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliFieldTest.java +++ /dev/null @@ -1,250 +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.psi.PsiField; -import com.intellij.psi.PsiPrimitiveType; -import com.intellij.psi.PsiTypeElement; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.dexlib2.AccessFlags; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliField; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliModifierList; -import org.junit.Assert; - -public class SmaliFieldTest extends LightCodeInsightFixtureTestCase { - public void testBasicField() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".field public myField:I"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - SmaliField[] fields = smaliClass.getFields(); - Assert.assertEquals(1, fields.length); - Assert.assertEquals("myField", fields[0].getName()); - Assert.assertTrue(fields[0].getType() instanceof PsiPrimitiveType); - Assert.assertEquals("int", fields[0].getType().getCanonicalText()); - PsiTypeElement typeElement = fields[0].getTypeElement(); - Assert.assertNotNull("I", typeElement); - Assert.assertEquals("I", typeElement.getText()); - - SmaliModifierList modifierList = fields[0].getModifierList(); - Assert.assertNotNull(modifierList); - Assert.assertEquals(AccessFlags.PUBLIC.getValue(), modifierList.getAccessFlags()); - Assert.assertTrue(modifierList.hasExplicitModifier("public")); - Assert.assertTrue(modifierList.hasModifierProperty("public")); - Assert.assertTrue(fields[0].hasModifierProperty("public")); - - PsiField[] psifields = smaliClass.getAllFields(); - Assert.assertEquals(1, psifields.length); - Assert.assertEquals("myField", psifields[0].getName()); - - PsiField field = smaliClass.findFieldByName("myField", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("nonExistantField", true); - Assert.assertNull(field); - field = smaliClass.findFieldByName("nonExistantField", false); - Assert.assertNull(field); - } - - public void testSmaliSuperField() { - myFixture.addFileToProject("my/pkg/base.smali", - ".class public Lmy/pkg/base; .super Ljava/lang/Object;\n" + - ".field public baseField:I"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Lmy/pkg/base;\n" + - ".field public myField:I"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - PsiField[] fields = smaliClass.getFields(); - Assert.assertEquals(1, fields.length); - Assert.assertEquals("myField", fields[0].getName()); - - fields = smaliClass.getAllFields(); - Assert.assertEquals(2, fields.length); - - Assert.assertTrue(fields[0].getName().equals("myField") || fields[1].getName().equals("myField")); - Assert.assertTrue(fields[0].getName().equals("baseField") || fields[1].getName().equals("baseField")); - - PsiField field = smaliClass.findFieldByName("myField", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("myField", false); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("baseField", false); - Assert.assertNull(field); - - field = smaliClass.findFieldByName("baseField", true); - Assert.assertNotNull(field); - Assert.assertEquals("baseField", field.getName()); - - field = smaliClass.findFieldByName("nonExistantField", true); - Assert.assertNull(field); - field = smaliClass.findFieldByName("nonExistantField", false); - Assert.assertNull(field); - } - - public void testJavaSuperField() { - myFixture.addFileToProject("my/pkg/base.java", - "package my.pkg; public class base { public int baseField; }"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Lmy/pkg/base;\n" + - ".field public myField:I"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - PsiField[] fields = smaliClass.getFields(); - Assert.assertEquals(1, fields.length); - Assert.assertEquals("myField", fields[0].getName()); - - fields = smaliClass.getAllFields(); - Assert.assertEquals(2, fields.length); - - Assert.assertTrue(fields[0].getName().equals("myField") || fields[1].getName().equals("myField")); - Assert.assertTrue(fields[0].getName().equals("baseField") || fields[1].getName().equals("baseField")); - - PsiField field = smaliClass.findFieldByName("myField", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("myField", false); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("baseField", false); - Assert.assertNull(field); - - field = smaliClass.findFieldByName("baseField", true); - Assert.assertNotNull(field); - Assert.assertEquals("baseField", field.getName()); - - field = smaliClass.findFieldByName("nonExistantField", true); - Assert.assertNull(field); - field = smaliClass.findFieldByName("nonExistantField", false); - Assert.assertNull(field); - } - - public void testMultipleField() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".field public myField:I\n" + - ".field public myField2:Ljava/lang/String;\n" + - ".field public myField3:[Ljava/lang/String;\n" + - ".field public myField4:[[[Ljava/lang/String;\n"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - SmaliField[] fields = smaliClass.getFields(); - Assert.assertEquals(4, fields.length); - Assert.assertEquals("myField", fields[0].getName()); - Assert.assertEquals("myField2", fields[1].getName()); - Assert.assertEquals("myField3", fields[2].getName()); - Assert.assertEquals("myField4", fields[3].getName()); - Assert.assertEquals("int", fields[0].getType().getCanonicalText()); - Assert.assertEquals("java.lang.String", fields[1].getType().getCanonicalText()); - Assert.assertEquals("java.lang.String[]", fields[2].getType().getCanonicalText()); - Assert.assertEquals("java.lang.String[][][]", fields[3].getType().getCanonicalText()); - - PsiField field = smaliClass.findFieldByName("myField", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("myField2", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField2", field.getName()); - - field = smaliClass.findFieldByName("myField3", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField3", field.getName()); - - field = smaliClass.findFieldByName("myField4", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField4", field.getName()); - - field = smaliClass.findFieldByName("nonExistantField", true); - Assert.assertNull(field); - field = smaliClass.findFieldByName("nonExistantField", false); - Assert.assertNull(field); - } - - public void testFieldAnnotations() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".field public myField:I"); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName()); - - SmaliField[] fields = smaliClass.getFields(); - Assert.assertEquals(1, fields.length); - Assert.assertEquals("myField", fields[0].getName()); - Assert.assertTrue(fields[0].getType() instanceof PsiPrimitiveType); - Assert.assertEquals("int", fields[0].getType().getCanonicalText()); - PsiTypeElement typeElement = fields[0].getTypeElement(); - Assert.assertNotNull("I", typeElement); - Assert.assertEquals("I", typeElement.getText()); - - SmaliModifierList modifierList = fields[0].getModifierList(); - Assert.assertNotNull(modifierList); - Assert.assertEquals(AccessFlags.PUBLIC.getValue(), modifierList.getAccessFlags()); - Assert.assertTrue(modifierList.hasExplicitModifier("public")); - Assert.assertTrue(modifierList.hasModifierProperty("public")); - Assert.assertTrue(fields[0].hasModifierProperty("public")); - - PsiField[] psifields = smaliClass.getAllFields(); - Assert.assertEquals(1, psifields.length); - Assert.assertEquals("myField", psifields[0].getName()); - - PsiField field = smaliClass.findFieldByName("myField", true); - Assert.assertNotNull(field); - Assert.assertEquals("myField", field.getName()); - - field = smaliClass.findFieldByName("nonExistantField", true); - Assert.assertNull(field); - field = smaliClass.findFieldByName("nonExistantField", false); - Assert.assertNull(field); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliFileTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliFileTest.java deleted file mode 100644 index e55bdd39..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliFileTest.java +++ /dev/null @@ -1,57 +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.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.junit.Assert; - -public class SmaliFileTest extends LightCodeInsightFixtureTestCase { - public void testFile() { - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;"); - - Assert.assertEquals(SmaliFileType.INSTANCE, file.getFileType()); - - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertNotNull(smaliClass); - - SmaliClass[] smaliClasses = file.getClasses(); - Assert.assertNotNull(smaliClasses); - Assert.assertEquals(1, smaliClasses.length); - Assert.assertEquals(smaliClass, smaliClasses[0]); - - String packageName = file.getPackageName(); - Assert.assertEquals("my.pkg", packageName); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliFileTypeTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliFileTypeTest.java deleted file mode 100644 index c2d7336d..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliFileTypeTest.java +++ /dev/null @@ -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; - -import com.intellij.psi.PsiFile; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.junit.Assert; - -/** - * Tests that .smali files are properly detected - */ -public class SmaliFileTypeTest extends LightCodeInsightFixtureTestCase { - public void testImportSmaliClass() { - PsiFile file = myFixture.addFileToProject("my/pkg/blah.smali", ".class public Lmy/pkg/blah; .super Ljava/lang/Object;"); - Assert.assertEquals(SmaliFileType.INSTANCE, file.getVirtualFile().getFileType()); - Assert.assertEquals(SmaliFileType.INSTANCE, file.getFileType()); - Assert.assertEquals(SmaliLanguage.INSTANCE, file.getLanguage()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliImplementsExtendsTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliImplementsExtendsTest.java deleted file mode 100644 index 597cf708..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliImplementsExtendsTest.java +++ /dev/null @@ -1,124 +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.psi.PsiClass; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliExtendsList; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliImplementsList; -import org.junit.Assert; - -public class SmaliImplementsExtendsTest extends LightCodeInsightFixtureTestCase { - public void testNormalClass() { - myFixture.addFileToProject("my/pkg/base.smali", - ".class public Lmy/pkg/base; .super Ljava/lang/Object;"); - myFixture.addFileToProject("my/pkg/iface.smali", - ".class public Lmy/pkg/iface; .super Ljava/lang/Object;"); - myFixture.addFileToProject("my/pkg/iface2.smali", - ".class public Lmy/pkg/iface2; .super Ljava/lang/Object;"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public Lmy/pkg/blah; .implements Lmy/pkg/iface; .super Lmy/pkg/base; " + - ".implements Lmy/pkg/iface2;"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliExtendsList extendsList = smaliClass.getExtendsList(); - Assert.assertEquals(1, extendsList.getReferencedTypes().length); - Assert.assertEquals("my.pkg.base", extendsList.getReferencedTypes()[0].getCanonicalText()); - Assert.assertEquals(1, extendsList.getReferenceNames().length); - Assert.assertEquals("my.pkg.base", extendsList.getReferenceNames()[0]); - Assert.assertEquals(1, smaliClass.getExtendsListTypes().length); - Assert.assertEquals("my.pkg.base", smaliClass.getExtendsListTypes()[0].getCanonicalText()); - - PsiClass resolvedSuper = extendsList.getReferencedTypes()[0].resolve(); - Assert.assertNotNull(resolvedSuper); - Assert.assertEquals("my.pkg.base", resolvedSuper.getQualifiedName()); - - SmaliImplementsList implementsList = smaliClass.getImplementsList(); - Assert.assertEquals(2, implementsList.getReferencedTypes().length); - Assert.assertEquals("my.pkg.iface", implementsList.getReferencedTypes()[0].getCanonicalText()); - Assert.assertEquals("my.pkg.iface2", implementsList.getReferencedTypes()[1].getCanonicalText()); - Assert.assertEquals(2, implementsList.getReferenceNames().length); - Assert.assertEquals("my.pkg.iface", implementsList.getReferenceNames()[0]); - Assert.assertEquals("my.pkg.iface2", implementsList.getReferenceNames()[1]); - Assert.assertEquals(2, smaliClass.getImplementsListTypes().length); - Assert.assertEquals("my.pkg.iface", smaliClass.getImplementsListTypes()[0].getCanonicalText()); - Assert.assertEquals("my.pkg.iface2", smaliClass.getImplementsListTypes()[1].getCanonicalText()); - - PsiClass resolvedInterface = implementsList.getReferencedTypes()[0].resolve(); - Assert.assertNotNull(resolvedInterface); - Assert.assertEquals("my.pkg.iface", resolvedInterface.getQualifiedName()); - - resolvedInterface = implementsList.getReferencedTypes()[1].resolve(); - Assert.assertNotNull(resolvedInterface); - Assert.assertEquals("my.pkg.iface2", resolvedInterface.getQualifiedName()); - } - - public void testInterface() { - myFixture.addFileToProject("my/pkg/iface.smali", - ".class public Lmy/pkg/iface; .super Ljava/lang/Object;"); - myFixture.addFileToProject("my/pkg/iface2.smali", - ".class public Lmy/pkg/iface2; .super Ljava/lang/Object;"); - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - ".class public interface Lmy/pkg/blah; .implements Lmy/pkg/iface; .super Ljava/lang/Object; " + - ".implements Lmy/pkg/iface2;"); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliExtendsList extendsList = smaliClass.getExtendsList(); - - Assert.assertEquals(2, extendsList.getReferencedTypes().length); - Assert.assertEquals("my.pkg.iface", extendsList.getReferencedTypes()[0].getCanonicalText()); - Assert.assertEquals("my.pkg.iface2", extendsList.getReferencedTypes()[1].getCanonicalText()); - Assert.assertEquals(2, extendsList.getReferenceNames().length); - Assert.assertEquals("my.pkg.iface", extendsList.getReferenceNames()[0]); - Assert.assertEquals("my.pkg.iface2", extendsList.getReferenceNames()[1]); - Assert.assertEquals(2, smaliClass.getExtendsListTypes().length); - Assert.assertEquals("my.pkg.iface", smaliClass.getExtendsListTypes()[0].getCanonicalText()); - Assert.assertEquals("my.pkg.iface2", smaliClass.getExtendsListTypes()[1].getCanonicalText()); - - PsiClass resolvedInterface = extendsList.getReferencedTypes()[0].resolve(); - Assert.assertNotNull(resolvedInterface); - Assert.assertEquals("my.pkg.iface", resolvedInterface.getQualifiedName()); - - resolvedInterface = extendsList.getReferencedTypes()[1].resolve(); - Assert.assertNotNull(resolvedInterface); - Assert.assertEquals("my.pkg.iface2", resolvedInterface.getQualifiedName()); - - SmaliImplementsList implementsList = smaliClass.getImplementsList(); - Assert.assertEquals(0, implementsList.getReferencedTypes().length); - Assert.assertEquals(0, implementsList.getReferenceNames().length); - Assert.assertEquals(0, smaliClass.getImplementsListTypes().length); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliInstructionTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliInstructionTest.java deleted file mode 100644 index 37ea555c..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliInstructionTest.java +++ /dev/null @@ -1,82 +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.psi.PsiElement; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.dexlib2.Opcode; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliInstruction; -import org.junit.Assert; - -public class SmaliInstructionTest extends LightCodeInsightFixtureTestCase { - public void testSingleInstruction() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah(IJLjava/lang/String;)V\n" + - " .locals 0\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliInstruction instructionElement = (SmaliInstruction)leafElement.getParent(); - Assert.assertNotNull(instructionElement); - - Assert.assertEquals(Opcode.RETURN_VOID, instructionElement.getOpcode()); - Assert.assertEquals(0, instructionElement.getOffset()); - } - - public void testMultipleInstructions() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah(IJLjava/lang/String;)I\n" + - " .locals 1\n" + - " const v0, 1234\n" + - " return v0\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliInstruction instructionElement = (SmaliInstruction)leafElement.getParent(); - Assert.assertNotNull(instructionElement); - - Assert.assertEquals(Opcode.RETURN, instructionElement.getOpcode()); - Assert.assertEquals(6, instructionElement.getOffset()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliLabelReferenceTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliLabelReferenceTest.java deleted file mode 100644 index 628cf0f5..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliLabelReferenceTest.java +++ /dev/null @@ -1,102 +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; - -import com.intellij.testFramework.ResolveTestCase; -import org.jf.dexlib2.Opcode; -import org.jf.smalidea.psi.impl.SmaliInstruction; -import org.jf.smalidea.psi.impl.SmaliLabel; -import org.jf.smalidea.psi.impl.SmaliLabelReference; -import org.junit.Assert; - -public class SmaliLabelReferenceTest extends ResolveTestCase { - - public void testLabelReference() throws Exception { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public getRandomParentType(I)I\n" + - " .registers 4\n" + - " .param p1, \"edge\" # I\n" + - "\n" + - " .prologue\n" + - " const/4 v1, 0x2\n" + - "\n" + - " .line 179\n" + - " if-nez p1, :cond_5\n" + - "\n" + - " move v0, v1\n" + - "\n" + - " .line 185\n" + - " :goto_4\n" + - " return v0\n" + - "\n" + - " .line 182\n" + - " :cond_5\n" + - " if-ne p1, v1, :cond_f\n" + - "\n" + - " .line 183\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " const/4 v1, 0x3\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - "\n" + - " .line 185\n" + - " :cond_f\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - ".end method";; - - SmaliLabelReference labelReference = (SmaliLabelReference)configureByFileText(text, "blah.smali"); - - Assert.assertNotNull(labelReference); - Assert.assertEquals("goto_4", labelReference.getName()); - - SmaliLabel resolvedLabel = labelReference.resolve(); - Assert.assertNotNull(resolvedLabel); - Assert.assertEquals("goto_4", resolvedLabel.getName()); - - SmaliInstruction nextInstruction = resolvedLabel.findNextSiblingByClass(SmaliInstruction.class); - Assert.assertNotNull(nextInstruction); - Assert.assertEquals(8, nextInstruction.getOffset()); - Assert.assertEquals(Opcode.RETURN, nextInstruction.getOpcode()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliLexerTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliLexerTest.java deleted file mode 100644 index 8383f966..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliLexerTest.java +++ /dev/null @@ -1,204 +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.testFramework.LexerTestCase; - -import java.util.Random; - -/** - * This is mostly just a smoke test to make sure the lexer is working. The lexer itself has its - * own tests in the smali module - */ -public class SmaliLexerTest extends LexerTestCase { - public void testHelloWorld() { - String text = - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 2\n" + - " sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;\n" + - " const-string v1, \"Hello World!\"\n" + - " invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V\n" + - " return-void\n" + - ".end method"; - - doTest(text, - "CLASS_DIRECTIVE ('.class')\n" + - "WHITE_SPACE (' ')\n" + - "ACCESS_SPEC ('public')\n" + - "WHITE_SPACE (' ')\n" + - "CLASS_DESCRIPTOR ('LHelloWorld;')\n" + - "WHITE_SPACE ('\\n')\n" + - "SUPER_DIRECTIVE ('.super')\n" + - "WHITE_SPACE (' ')\n" + - "CLASS_DESCRIPTOR ('Ljava/lang/Object;')\n" + - "WHITE_SPACE ('\\n')\n" + - "METHOD_DIRECTIVE ('.method')\n" + - "WHITE_SPACE (' ')\n" + - "ACCESS_SPEC ('public')\n" + - "WHITE_SPACE (' ')\n" + - "ACCESS_SPEC ('static')\n" + - "WHITE_SPACE (' ')\n" + - "SIMPLE_NAME ('main')\n" + - "OPEN_PAREN ('(')\n" + - "ARRAY_TYPE_PREFIX ('[')\n" + - "CLASS_DESCRIPTOR ('Ljava/lang/String;')\n" + - "CLOSE_PAREN (')')\n" + - "VOID_TYPE ('V')\n" + - "WHITE_SPACE ('\\n ')\n" + - "REGISTERS_DIRECTIVE ('.registers')\n" + - "WHITE_SPACE (' ')\n" + - "POSITIVE_INTEGER_LITERAL ('2')\n" + - "WHITE_SPACE ('\\n ')\n" + - "INSTRUCTION_FORMAT21c_FIELD ('sget-object')\n" + - "WHITE_SPACE (' ')\n" + - "REGISTER ('v0')\n" + - "COMMA (',')\n" + - "WHITE_SPACE (' ')\n" + - "CLASS_DESCRIPTOR ('Ljava/lang/System;')\n" + - "ARROW ('->')\n" + - "SIMPLE_NAME ('out')\n" + - "COLON (':')\n" + - "CLASS_DESCRIPTOR ('Ljava/io/PrintStream;')\n" + - "WHITE_SPACE ('\\n ')\n" + - "INSTRUCTION_FORMAT21c_STRING ('const-string')\n" + - "WHITE_SPACE (' ')\n" + - "REGISTER ('v1')\n" + - "COMMA (',')\n" + - "WHITE_SPACE (' ')\n" + - "STRING_LITERAL ('\"Hello World!\"')\n" + - "WHITE_SPACE ('\\n ')\n" + - "INSTRUCTION_FORMAT35c_METHOD ('invoke-virtual')\n" + - "WHITE_SPACE (' ')\n" + - "OPEN_BRACE ('{')\n" + - "REGISTER ('v0')\n" + - "COMMA (',')\n" + - "WHITE_SPACE (' ')\n" + - "REGISTER ('v1')\n" + - "CLOSE_BRACE ('}')\n" + - "COMMA (',')\n" + - "WHITE_SPACE (' ')\n" + - "CLASS_DESCRIPTOR ('Ljava/io/PrintStream;')\n" + - "ARROW ('->')\n" + - "SIMPLE_NAME ('println')\n" + - "OPEN_PAREN ('(')\n" + - "CLASS_DESCRIPTOR ('Ljava/lang/String;')\n" + - "CLOSE_PAREN (')')\n" + - "VOID_TYPE ('V')\n" + - "WHITE_SPACE ('\\n ')\n" + - "INSTRUCTION_FORMAT10x ('return-void')\n" + - "WHITE_SPACE ('\\n')\n" + - "END_METHOD_DIRECTIVE ('.end method')" - ); - } - - @Override protected Lexer createLexer() { - return new SmaliLexer(); - } - - @Override protected String getDirPath() { - return ""; - } - - public void testErrorToken() { - String text = ".class public .blah"; - doTest(text, - "CLASS_DIRECTIVE ('.class')\n" + - "WHITE_SPACE (' ')\n" + - "ACCESS_SPEC ('public')\n" + - "WHITE_SPACE (' ')\n" + - "BAD_CHARACTER ('.blah')\n"); - } - - /** - * Type out an example smali file character by character, ensuring that no exceptions are thrown - */ - public void testPartialText() { - String text = - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 2\n" + - " sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;\n" + - " const-string v1, \"Hello World!\"\n" + - " invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V\n" + - " return-void\n" + - ".end method"; - - for (int i=1; i 4) { - sb.append((char)random.nextInt(256)); - } else if (type == 4) { - sb.append(' '); - } else { - sb.append((char)random.nextInt(128)); - } - } - - return sb.toString(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliLiteralTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliLiteralTest.java deleted file mode 100644 index 64d38a93..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliLiteralTest.java +++ /dev/null @@ -1,78 +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.psi.PsiElement; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliLiteral; -import org.junit.Assert; - -public class SmaliLiteralTest extends LightCodeInsightFixtureTestCase { - private void doTest(long expectedValue, String literalValue) { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah()V\n" + - " .registers " + literalValue + "\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliLiteral literalElement = (SmaliLiteral)leafElement.getParent(); - Assert.assertNotNull(literalElement); - - Assert.assertEquals(expectedValue, literalElement.getIntegralValue()); - } - - public void testIntegerValue() { - doTest(123, "123"); - } - - public void testLongValue() { - doTest(100, "100L"); - } - - public void testShortValue() { - doTest(99, "99s"); - } - - public void testByteValue() { - doTest(127, "127t"); - } - - // TODO: test char - // TODO: test bool -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliMethodTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliMethodTest.java deleted file mode 100644 index 6af96757..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliMethodTest.java +++ /dev/null @@ -1,309 +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.debugger.SourcePosition; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiPrimitiveType; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.dexlib2.Opcode; -import org.jf.smalidea.psi.impl.*; -import org.junit.Assert; - -import java.util.List; - -public class SmaliMethodTest extends LightCodeInsightFixtureTestCase { - public void testMethodRegisters() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah()V\n" + - " .registers 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliMethod methodElement = (SmaliMethod)leafElement.getParent(); - Assert.assertNotNull(methodElement); - - Assert.assertEquals(123, methodElement.getRegisterCount()); - Assert.assertEquals(1, methodElement.getParameterRegisterCount()); - } - - public void testMethodRegisters2() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah(IJLjava/lang/String;)V\n" + - " .locals 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliMethod methodElement = (SmaliMethod)leafElement.getParent(); - Assert.assertNotNull(methodElement); - - Assert.assertEquals(128, methodElement.getRegisterCount()); - Assert.assertEquals(5, methodElement.getParameterRegisterCount()); - } - - public void testStaticRegisterCount() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method static blah(IJLjava/lang/String;)V\n" + - " .locals 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - Assert.assertEquals(127, smaliMethod.getRegisterCount()); - Assert.assertEquals(4, smaliMethod.getParameterRegisterCount()); - - Assert.assertEquals(0, smaliMethod.getParameterList().getParameters()[0].getParameterRegisterNumber()); - Assert.assertEquals(123, smaliMethod.getParameterList().getParameters()[0].getRegisterNumber()); - } - - public void testMethodParams() { - myFixture.addFileToProject("my/TestAnnotation.smali", - ".class public interface abstract annotation Lmy/TestAnnotation;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract testBooleanValue()Z\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringArrayValue()[Ljava/lang/String;\n" + - ".end method\n" + - "\n" + - ".method public abstract testStringValue()Ljava/lang/String;\n" + - ".end method"); - - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah(IJLjava/lang/String;)V\n" + - " .locals 123\n" + - " .param p1, \"anInt\"\n" + - " .param p2\n" + - " .annotation runtime Lmy/TestAnnotation;\n" + - " testStringValue = \"myValue\"\n" + - " .end annotation\n" + - " .end param\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmaliMethodParamList paramList = smaliMethod.getParameterList(); - SmaliMethodParameter[] parameters = paramList.getParameters(); - Assert.assertEquals(3, parameters.length); - - Assert.assertEquals("int", parameters[0].getType().getCanonicalText()); - Assert.assertEquals("\"anInt\"", parameters[0].getName()); - Assert.assertEquals(1, parameters[0].getRegisterCount()); - Assert.assertEquals(124, parameters[0].getRegisterNumber()); - Assert.assertEquals(1, parameters[0].getParameterRegisterNumber()); - Assert.assertEquals(0, parameters[0].getAnnotations().length); - - Assert.assertEquals("long", parameters[1].getType().getCanonicalText()); - Assert.assertNull(parameters[1].getName()); - Assert.assertEquals(2, parameters[1].getRegisterCount()); - Assert.assertEquals(125, parameters[1].getRegisterNumber()); - Assert.assertEquals(2, parameters[1].getParameterRegisterNumber()); - Assert.assertEquals(1, parameters[1].getAnnotations().length); - Assert.assertEquals("my.TestAnnotation", parameters[1].getAnnotations()[0].getQualifiedName()); - - Assert.assertEquals("java.lang.String", parameters[2].getType().getCanonicalText()); - Assert.assertNull(parameters[2].getName()); - Assert.assertEquals(1, parameters[2].getRegisterCount()); - Assert.assertEquals(127, parameters[2].getRegisterNumber()); - Assert.assertEquals(4, parameters[2].getParameterRegisterNumber()); - Assert.assertEquals(0, parameters[2].getAnnotations().length); - } - - public void testVarArgsMethod() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method varargs static blah(IJ[Ljava/lang/String;)V\n" + - " .locals 123\n" + - " return-void\n" + - ".end method\n" + - ".method varargs static blah2(IJLjava/lang/String;)V\n" + - " .locals 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - Assert.assertTrue(smaliMethod.isVarArgs()); - Assert.assertFalse(smaliMethod.getParameterList().getParameters()[0].isVarArgs()); - Assert.assertFalse(smaliMethod.getParameterList().getParameters()[1].isVarArgs()); - Assert.assertTrue(smaliMethod.getParameterList().getParameters()[2].isVarArgs()); - - smaliMethod = smaliClass.getMethods()[1]; - Assert.assertTrue(smaliMethod.isVarArgs()); - Assert.assertFalse(smaliMethod.getParameterList().getParameters()[0].isVarArgs()); - Assert.assertFalse(smaliMethod.getParameterList().getParameters()[1].isVarArgs()); - Assert.assertFalse(smaliMethod.getParameterList().getParameters()[2].isVarArgs()); - } - - private static final String instructionsTestClass = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public getRandomParentType(I)I\n" + - " .registers 4\n" + - " .param p1, \"edge\" # I\n" + - "\n" + - " .prologue\n" + - " const/4 v1, 0x2\n" + - "\n" + - " .line 179\n" + - " if-nez p1, :cond_5\n" + - "\n" + - " move v0, v1\n" + - "\n" + - " .line 185\n" + - " :goto_4\n" + - " return v0\n" + - "\n" + - " .line 182\n" + - " :cond_5\n" + - " if-ne p1, v1, :cond_f\n" + - "\n" + - " .line 183\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " const/4 v1, 0x3\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - "\n" + - " .line 185\n" + - " :cond_f\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - ".end method"; - - public void testGetInstructions() { - String text = instructionsTestClass; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - List instructions = smaliMethod.getInstructions(); - Assert.assertEquals(14, instructions.size()); - } - - private void checkSourcePosition(SmaliMethod smaliMethod, int codeOffset, Opcode opcode) { - SourcePosition sourcePosition = smaliMethod.getSourcePositionForCodeOffset(codeOffset); - Assert.assertNotNull(sourcePosition); - - SmaliInstruction instruction = (SmaliInstruction)sourcePosition.getElementAt(); - Assert.assertEquals(opcode, instruction.getOpcode()); - Assert.assertEquals(codeOffset, instruction.getOffset()); - } - - public void testGetSourcePositionForCodeOffset() { - String text = instructionsTestClass; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - checkSourcePosition(smaliMethod, 0, Opcode.CONST_4); - checkSourcePosition(smaliMethod, 2, Opcode.IF_NEZ); - checkSourcePosition(smaliMethod, 6, Opcode.MOVE); - checkSourcePosition(smaliMethod, 8, Opcode.RETURN); - checkSourcePosition(smaliMethod, 10, Opcode.IF_NE); - checkSourcePosition(smaliMethod, 14, Opcode.SGET_OBJECT); - checkSourcePosition(smaliMethod, 18, Opcode.CONST_4); - checkSourcePosition(smaliMethod, 20, Opcode.INVOKE_VIRTUAL); - checkSourcePosition(smaliMethod, 26, Opcode.MOVE_RESULT); - checkSourcePosition(smaliMethod, 28, Opcode.GOTO); - checkSourcePosition(smaliMethod, 30, Opcode.SGET_OBJECT); - checkSourcePosition(smaliMethod, 34, Opcode.INVOKE_VIRTUAL); - checkSourcePosition(smaliMethod, 40, Opcode.MOVE_RESULT); - checkSourcePosition(smaliMethod, 42, Opcode.GOTO); - } - - public void testThrowsList() { - String text = instructionsTestClass; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmaliThrowsList throwsList = smaliMethod.getThrowsList(); - Assert.assertNotNull(throwsList); - Assert.assertEquals(0, throwsList.getReferencedTypes().length); - Assert.assertEquals(0, throwsList.getReferenceElements().length); - } - - public void testPrimitiveReturnType() { - String text = "" + - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah()I\n" + - " .registers 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - Assert.assertNotNull(smaliClass); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - Assert.assertNotNull(smaliMethod.getReturnType()); - Assert.assertTrue(smaliMethod.getReturnType().isConvertibleFrom(PsiPrimitiveType.INT)); - Assert.assertTrue(smaliMethod.getReturnType().isAssignableFrom(PsiPrimitiveType.INT)); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliPositionManagerTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliPositionManagerTest.java deleted file mode 100644 index 596c11ed..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliPositionManagerTest.java +++ /dev/null @@ -1,237 +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.debugger.NoDataException; -import com.intellij.debugger.PositionManager; -import com.intellij.debugger.SourcePosition; -import com.intellij.debugger.engine.DebugProcess; -import com.intellij.debugger.engine.DebugProcessListener; -import com.intellij.debugger.engine.evaluation.EvaluateException; -import com.intellij.debugger.engine.evaluation.EvaluationContext; -import com.intellij.debugger.engine.jdi.VirtualMachineProxy; -import com.intellij.debugger.engine.managerThread.DebuggerManagerThread; -import com.intellij.debugger.requests.RequestManager; -import com.intellij.execution.ExecutionResult; -import com.intellij.execution.process.ProcessHandler; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import com.sun.jdi.*; -import org.jetbrains.annotations.NotNull; -import org.jf.dexlib2.Opcode; -import org.jf.smalidea.debugging.SmaliPositionManager; -import org.jf.smalidea.psi.impl.SmaliInstruction; -import org.junit.Assert; - -import java.util.List; -import java.util.Map; - -public class SmaliPositionManagerTest extends LightCodeInsightFixtureTestCase { - private static final String testClass = - "\n\n.class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public getRandomParentType(I)I\n" + - " .registers 4\n" + - " .param p1, \"edge\" # I\n" + - "\n" + - " .prologue\n" + - " const/4 v1, 0x2\n" + - "\n" + - " .line 179\n" + - " if-nez p1, :cond_5\n" + - "\n" + - " move v0, v1\n" + - "\n" + - " .line 185\n" + - " :goto_4\n" + - " return v0\n" + - "\n" + - " .line 182\n" + - " :cond_5\n" + - " if-ne p1, v1, :cond_f\n" + - "\n" + - " .line 183\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " const/4 v1, 0x3\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - "\n" + - " .line 185\n" + - " :cond_f\n" + - " sget-object v0, Lorg/jf/Penroser/PenroserApp;->random:Ljava/util/Random;\n" + - "\n" + - " invoke-virtual {v0, v1}, Ljava/util/Random;->nextInt(I)I\n" + - "\n" + - " move-result v0\n" + - "\n" + - " goto :goto_4\n" + - ".end method"; - - public void testGetSourcePosition() throws NoDataException { - myFixture.addFileToProject("my/pkg/blah.smali", testClass); - - SmaliPositionManager positionManager = new SmaliPositionManager(new MockDebugProcess()); - - SourcePosition sourcePosition = positionManager.getSourcePosition( - "my.pkg.blah", "getRandomParentType", "(I)I", 0); - Assert.assertEquals(Opcode.CONST_4, ((SmaliInstruction)sourcePosition.getElementAt()).getOpcode()); - Assert.assertEquals(0, ((SmaliInstruction)sourcePosition.getElementAt()).getOffset()); - - sourcePosition = positionManager.getSourcePosition("my.pkg.blah", "getRandomParentType", "(I)I", 10); - Assert.assertEquals(Opcode.INVOKE_VIRTUAL, ((SmaliInstruction)sourcePosition.getElementAt()).getOpcode()); - Assert.assertEquals(20, ((SmaliInstruction)sourcePosition.getElementAt()).getOffset()); - } - - public void testGetAllClasses() throws NoDataException { - myFixture.addFileToProject("my/pkg/blah.smali", testClass); - - SmaliPositionManager positionManager = new SmaliPositionManager(new MockDebugProcess()); - - List classes = positionManager.getAllClasses(positionManager.getSourcePosition( - "my.pkg.blah", "getRandomParentType", "(I)I", 0)); - Assert.assertEquals(1, classes.size()); - Assert.assertEquals("my.pkg.blah", classes.get(0).name()); - } - - private class MockDebugProcess implements DebugProcess { - @Override public Project getProject() { - return SmaliPositionManagerTest.this.getProject(); - } - - @Override public VirtualMachineProxy getVirtualMachineProxy() { - return new VirtualMachineProxy() { - @Override public List classesByName(final String s) { - return Lists.newArrayList(new MockReferenceType(s)); - } - - @Override public List allClasses() { return null; } - @Override public boolean canGetBytecodes() { return false; } - @Override public boolean versionHigher(String version) { return false; } - @Override public boolean canWatchFieldModification() { return false; } - @Override public boolean canWatchFieldAccess() { return false; } - @Override public boolean canInvokeMethods() { return false; } - @Override public DebugProcess getDebugProcess() { return null; } - @Override public List nestedTypes(ReferenceType refType) { return null; } - }; - } - - @Override public void addDebugProcessListener(DebugProcessListener listener) {} - @Override public T getUserData(Key key) { return null; } - @Override public void putUserData(Key key, T value) {} - @Override public RequestManager getRequestsManager() { return null; } - @Override public PositionManager getPositionManager() { return null; } - @Override public void removeDebugProcessListener(DebugProcessListener listener) {} - @Override public void appendPositionManager(PositionManager positionManager) {} - @Override public void waitFor() {} - @Override public void waitFor(long timeout) {} - @Override public void stop(boolean forceTerminate) {} - @Override public ExecutionResult getExecutionResult() { return null; } - @Override public DebuggerManagerThread getManagerThread() { return null; } - @Override public Value invokeMethod(EvaluationContext evaluationContext, ObjectReference objRef, Method method, List args) throws EvaluateException { return null; } - @Override public Value invokeMethod(EvaluationContext evaluationContext, ClassType classType, Method method, List args) throws EvaluateException { return null; } - @Override public Value invokeInstanceMethod(EvaluationContext evaluationContext, ObjectReference objRef, Method method, List args, int invocationOptions) throws EvaluateException { return null; } - @Override public ReferenceType findClass(EvaluationContext evaluationContext, String name, ClassLoaderReference classLoader) throws EvaluateException { return null; } - @Override public ArrayReference newInstance(ArrayType arrayType, int dimension) throws EvaluateException { return null; } - @Override public ObjectReference newInstance(EvaluationContext evaluationContext, ClassType classType, Method constructor, List paramList) throws EvaluateException { return null; } - @Override public boolean isAttached() { return false; } - @Override public boolean isDetached() { return false; } - @Override public boolean isDetaching() { return false; } - @NotNull @Override public GlobalSearchScope getSearchScope() { return null; } - @Override public void printToConsole(String text) {} - @Override public ProcessHandler getProcessHandler() { return null; } - } - - private static class MockReferenceType implements ReferenceType { - private final String name; - - public MockReferenceType(String name) { - this.name = name; - } - - @Override public String name() { - return name; - } - - @Override public List allFields() { return null; } - @Override public String genericSignature() { return null; } - @Override public ClassLoaderReference classLoader() { return null; } - @Override public String sourceName() throws AbsentInformationException { return null; } - @Override public List sourceNames(String s) throws AbsentInformationException { return null; } - @Override public List sourcePaths(String s) throws AbsentInformationException { return null; } - @Override public String sourceDebugExtension() throws AbsentInformationException { return null; } - @Override public boolean isStatic() { return false; } - @Override public boolean isAbstract() { return false; } - @Override public boolean isFinal() { return false; } - @Override public boolean isPrepared() { return false; } - @Override public boolean isVerified() { return false; } - @Override public boolean isInitialized() { return false; } - @Override public boolean failedToInitialize() { return false; } - @Override public List fields() { return null; } - @Override public List visibleFields() { return null; } - @Override public Field fieldByName(String s) { return null; } - @Override public List methods() { return null; } - @Override public List visibleMethods() { return null; } - @Override public List allMethods() { return null; } - @Override public List methodsByName(String s) { return null; } - @Override public List methodsByName(String s, String s1) { return null; } - @Override public List nestedTypes() { return null; } - @Override public Value getValue(Field field) { return null; } - @Override public Map getValues(List list) { return null; } - @Override public ClassObjectReference classObject() { return null; } - @Override public List allLineLocations() throws AbsentInformationException { return null; } - @Override public List allLineLocations(String s, String s1) throws AbsentInformationException { return null; } - @Override public List locationsOfLine(int i) throws AbsentInformationException { return null; } - @Override public List locationsOfLine(String s, String s1, int i) throws AbsentInformationException { return null; } - @Override public List availableStrata() { return null; } - @Override public String defaultStratum() { return null; } - @Override public List instances(long l) { return null; } - @Override public int majorVersion() { return 0; } - @Override public int minorVersion() { return 0; } - @Override public int constantPoolCount() { return 0; } - @Override public byte[] constantPool() { return new byte[0]; } - @Override public int modifiers() { return 0; } - @Override public boolean isPrivate() { return false; } - @Override public boolean isPackagePrivate() { return false; } - @Override public boolean isProtected() { return false; } - @Override public boolean isPublic() { return false; } - @Override public int compareTo(ReferenceType o) { return 0; } - @Override public String signature() { return null; } - @Override public VirtualMachine virtualMachine() { return null; } - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/SmaliRegisterTest.java b/smalidea/src/test/java/org/jf/smalidea/SmaliRegisterTest.java deleted file mode 100644 index fbb4b627..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/SmaliRegisterTest.java +++ /dev/null @@ -1,61 +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.psi.PsiElement; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliRegisterReference; -import org.junit.Assert; - -public class SmaliRegisterTest extends LightCodeInsightFixtureTestCase { - public void testRegisterReference() { - String text = - ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method blah()V\n" + - " .registers 123\n" + - " const v10, 123\n" + - " return-void\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", - text.replace("", "")); - - PsiElement leafElement = file.findElementAt(text.indexOf("")); - Assert.assertNotNull(leafElement); - SmaliRegisterReference registerReference = (SmaliRegisterReference)leafElement.getParent(); - Assert.assertNotNull(registerReference); - - Assert.assertEquals(10, registerReference.getRegisterNumber()); - // TODO: test parameter register - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/dexlib/SmalideaMethodTest.java b/smalidea/src/test/java/org/jf/smalidea/dexlib/SmalideaMethodTest.java deleted file mode 100644 index e9aa35fc..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/dexlib/SmalideaMethodTest.java +++ /dev/null @@ -1,580 +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 com.google.common.collect.Lists; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.ExceptionHandler; -import org.jf.dexlib2.iface.MethodImplementation; -import org.jf.dexlib2.iface.MethodParameter; -import org.jf.dexlib2.iface.TryBlock; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.SwitchElement; -import org.jf.dexlib2.iface.instruction.formats.*; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.StringReference; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.smalidea.psi.impl.SmaliClass; -import org.jf.smalidea.psi.impl.SmaliFile; -import org.jf.smalidea.psi.impl.SmaliMethod; -import org.junit.Assert; - -import java.util.List; - -public class SmalideaMethodTest extends LightCodeInsightFixtureTestCase { - - public void testSmalideaMethod() { - String text = ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public someMethodName(I)I\n" + - " .registers 4\n" + - " .param p1, \"edge\" # I\n" + - - " goto :here #0: 10t\n" + - " :here\n" + - " return-void #1: 21c\n" + - " const/4 v0, 1234 #2: 11n\n" + - " monitor-enter v1, #3: 11x\n" + - " move v1, v0 #4: 12x\n" + - " goto/16 :here #5: 20t\n" + - " sget v0, La/b/c;->blah:I #6: 21c\n" + - " const/high16 v0, 0x12340000 #7: 21ih\n" + - " const-wide/high16 v0, 0x1234000000000000L #8: 21lh\n" + - " const-wide/16 v0, 1234 #9: 21s\n" + - " if-eqz v0, :here #10: 21t\n" + - " add-int/lit8 v0, v1, 123 #11: 22b\n" + - " iget v1, v2, Labc;->blort:Z #12: 22c\n" + - " add-int/lit16 v0, v1, 1234 #13: 22s\n" + - " if-eq v0, v1, :here #14: 22t\n" + - " move/from16 v0, v1 #15: 22x\n" + - " cmpl-float v0, v1, v2 #16: 23x\n" + - " goto/32 :here #17: 30t\n" + - " const-string/jumbo v0, \"abcd\" #18: 31c\n" + - " const v0, 1234 #19: 31i\n" + - " move/16 v0, v1 #20: 32x\n" + - " invoke-virtual {v0, v1, v2, v3, v4}, Lblah;->blort(IIII)I #21: 35c\n" + - " invoke-virtual/range {v0..v4}, Lblah;->blort(IIII)I #22: 3rc\n" + - " const-wide v0, 0x1234567890L #23: 51i\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmalideaMethod method = new SmalideaMethod(smaliMethod); - Assert.assertEquals("Lmy/pkg/blah;", method.getDefiningClass()); - Assert.assertEquals("someMethodName", method.getName()); - Assert.assertEquals("I", method.getReturnType()); - - List parameterTypes = method.getParameterTypes(); - Assert.assertEquals(1, parameterTypes.size()); - Assert.assertEquals("I", parameterTypes.get(0)); - - List parameters = method.getParameters(); - Assert.assertEquals(1, parameters.size()); - Assert.assertEquals("I", parameters.get(0).getType()); - Assert.assertEquals("edge", parameters.get(0).getName()); - - Assert.assertEquals(AccessFlags.PUBLIC.getValue(), method.getAccessFlags()); - - MethodImplementation impl = method.getImplementation(); - Assert.assertNotNull(impl); - - Assert.assertEquals(4, impl.getRegisterCount()); - - List instructions = Lists.newArrayList(impl.getInstructions()); - - { - Instruction10t instruction = (Instruction10t)instructions.get(0); - Assert.assertEquals(Opcode.GOTO, instruction.getOpcode()); - Assert.assertEquals(1, instruction.getCodeOffset()); - } - - { - Instruction10x instruction = (Instruction10x)instructions.get(1); - Assert.assertEquals(Opcode.RETURN_VOID, instruction.getOpcode()); - } - - { - Instruction11n instruction = (Instruction11n)instructions.get(2); - Assert.assertEquals(Opcode.CONST_4, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1234, instruction.getNarrowLiteral()); - } - - { - Instruction11x instruction = (Instruction11x)instructions.get(3); - Assert.assertEquals(Opcode.MONITOR_ENTER, instruction.getOpcode()); - Assert.assertEquals(1, instruction.getRegisterA()); - } - - { - Instruction12x instruction = (Instruction12x)instructions.get(4); - Assert.assertEquals(Opcode.MOVE, instruction.getOpcode()); - Assert.assertEquals(1, instruction.getRegisterA()); - Assert.assertEquals(0, instruction.getRegisterB()); - } - - { - Instruction20t instruction = (Instruction20t)instructions.get(5); - Assert.assertEquals(Opcode.GOTO_16, instruction.getOpcode()); - Assert.assertEquals(-4, instruction.getCodeOffset()); - } - - { - Instruction21c instruction = (Instruction21c)instructions.get(6); - Assert.assertEquals(Opcode.SGET, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals("La/b/c;->blah:I", ReferenceUtil.getFieldDescriptor( - (FieldReference)instruction.getReference())); - } - - { - Instruction21ih instruction = (Instruction21ih)instructions.get(7); - Assert.assertEquals(Opcode.CONST_HIGH16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(0x1234, instruction.getHatLiteral()); - Assert.assertEquals(0x12340000, instruction.getNarrowLiteral()); - Assert.assertEquals(0x12340000, instruction.getWideLiteral()); - } - - { - Instruction21lh instruction = (Instruction21lh)instructions.get(8); - Assert.assertEquals(Opcode.CONST_WIDE_HIGH16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(0x1234, instruction.getHatLiteral()); - Assert.assertEquals(0x1234000000000000L, instruction.getWideLiteral()); - } - - { - Instruction21s instruction = (Instruction21s)instructions.get(9); - Assert.assertEquals(Opcode.CONST_WIDE_16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1234, instruction.getWideLiteral()); - } - - { - Instruction21t instruction = (Instruction21t)instructions.get(10); - Assert.assertEquals(Opcode.IF_EQZ, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(-14, instruction.getCodeOffset()); - } - - { - Instruction22b instruction = (Instruction22b)instructions.get(11); - Assert.assertEquals(Opcode.ADD_INT_LIT8, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - Assert.assertEquals(123, instruction.getNarrowLiteral()); - } - - { - Instruction22c instruction = (Instruction22c)instructions.get(12); - Assert.assertEquals(Opcode.IGET, instruction.getOpcode()); - Assert.assertEquals(1, instruction.getRegisterA()); - Assert.assertEquals(2, instruction.getRegisterB()); - Assert.assertEquals("Labc;->blort:Z", ReferenceUtil.getFieldDescriptor( - (FieldReference)instruction.getReference())); - } - - { - Instruction22s instruction = (Instruction22s)instructions.get(13); - Assert.assertEquals(Opcode.ADD_INT_LIT16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - Assert.assertEquals(1234, instruction.getNarrowLiteral()); - } - - { - Instruction22t instruction = (Instruction22t)instructions.get(14); - Assert.assertEquals(Opcode.IF_EQ, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - Assert.assertEquals(-22, instruction.getCodeOffset()); - } - - { - Instruction22x instruction = (Instruction22x)instructions.get(15); - Assert.assertEquals(Opcode.MOVE_FROM16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - } - - { - Instruction23x instruction = (Instruction23x)instructions.get(16); - Assert.assertEquals(Opcode.CMPL_FLOAT, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - Assert.assertEquals(2, instruction.getRegisterC()); - } - - { - Instruction30t instruction = (Instruction30t)instructions.get(17); - Assert.assertEquals(Opcode.GOTO_32, instruction.getOpcode()); - Assert.assertEquals(-28, instruction.getCodeOffset()); - } - - { - Instruction31c instruction = (Instruction31c)instructions.get(18); - Assert.assertEquals(Opcode.CONST_STRING_JUMBO, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals("abcd", ((StringReference)instruction.getReference()).getString()); - } - - { - Instruction31i instruction = (Instruction31i)instructions.get(19); - Assert.assertEquals(Opcode.CONST, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1234, instruction.getNarrowLiteral()); - } - - { - Instruction32x instruction = (Instruction32x)instructions.get(20); - Assert.assertEquals(Opcode.MOVE_16, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(1, instruction.getRegisterB()); - } - - { - Instruction35c instruction = (Instruction35c)instructions.get(21); - Assert.assertEquals(Opcode.INVOKE_VIRTUAL, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterC()); - Assert.assertEquals(1, instruction.getRegisterD()); - Assert.assertEquals(2, instruction.getRegisterE()); - Assert.assertEquals(3, instruction.getRegisterF()); - Assert.assertEquals(4, instruction.getRegisterG()); - Assert.assertEquals("Lblah;->blort(IIII)I", ReferenceUtil.getReferenceString(instruction.getReference())); - } - - { - Instruction3rc instruction = (Instruction3rc)instructions.get(22); - Assert.assertEquals(Opcode.INVOKE_VIRTUAL_RANGE, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getStartRegister()); - Assert.assertEquals(5, instruction.getRegisterCount()); - Assert.assertEquals("Lblah;->blort(IIII)I", ReferenceUtil.getReferenceString(instruction.getReference())); - } - - { - Instruction51l instruction = (Instruction51l)instructions.get(23); - Assert.assertEquals(Opcode.CONST_WIDE, instruction.getOpcode()); - Assert.assertEquals(0, instruction.getRegisterA()); - Assert.assertEquals(0x1234567890L, instruction.getWideLiteral()); - } - } - - public void testCatchBlocks() { - String text = ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + - ".method public onCreateEngine()Landroid/service/wallpaper/WallpaperService$Engine;\n" + - " .registers 5\n" + - "\n" + - " .prologue\n" + - " .line 88\n" + - " new-instance v0, Lorg/jf/Penroser/PenroserLiveWallpaper$PenroserGLEngine;\n" + - "\n" + - " invoke-direct {v0, p0}, Lorg/jf/Penroser/PenroserLiveWallpaper$PenroserGLEngine;->(Lorg/jf/Penroser/PenroserLiveWallpaper;)V\n" + - "\n" + - " .line 89\n" + - " .local v0, \"engine\":Lorg/jf/Penroser/PenroserLiveWallpaper$PenroserGLEngine;\n" + - " sget-object v1, Lorg/jf/Penroser/PenroserLiveWallpaper;->engines:Ljava/util/LinkedList;\n" + - "\n" + - " monitor-enter v1\n" + - "\n" + - " .line 90\n" + - " :try_start_8\n" + - " sget-object v2, Lorg/jf/Penroser/PenroserLiveWallpaper;->engines:Ljava/util/LinkedList;\n" + - "\n" + - " new-instance v3, Ljava/lang/ref/WeakReference;\n" + - "\n" + - " invoke-direct {v3, v0}, Ljava/lang/ref/WeakReference;->(Ljava/lang/Object;)V\n" + - "\n" + - " invoke-virtual {v2, v3}, Ljava/util/LinkedList;->addLast(Ljava/lang/Object;)V\n" + - "\n" + - " .line 91\n" + - " monitor-exit v1\n" + - "\n" + - " .line 92\n" + - " return-object v0\n" + - "\n" + - " .line 91\n" + - " :catchall_14\n" + - " move-exception v2\n" + - "\n" + - " monitor-exit v1\n" + - " :try_end_16\n" + - " .catch Ljava/lang/RuntimeException; {:try_start_8 .. :try_end_16} :newcatch\n" + - " .catchall {:try_start_8 .. :try_end_16} :catchall_14\n" + - "\n" + - " throw v2\n" + - "\n" + - " :newcatch\n" + - " move-exception v2\n" + - " throw v2\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmalideaMethod method = new SmalideaMethod(smaliMethod); - - MethodImplementation impl = method.getImplementation(); - Assert.assertNotNull(impl); - - List> tryBlocks = impl.getTryBlocks(); - Assert.assertEquals(2, tryBlocks.size()); - - TryBlock tryBlock = tryBlocks.get(0); - Assert.assertEquals(8, tryBlock.getStartCodeAddress()); - Assert.assertEquals(14, tryBlock.getCodeUnitCount()); - Assert.assertEquals(1, tryBlock.getExceptionHandlers().size()); - Assert.assertEquals("Ljava/lang/RuntimeException;", tryBlock.getExceptionHandlers().get(0).getExceptionType()); - Assert.assertEquals(23, tryBlock.getExceptionHandlers().get(0).getHandlerCodeAddress()); - - tryBlock = tryBlocks.get(1); - Assert.assertEquals(8, tryBlock.getStartCodeAddress()); - Assert.assertEquals(14, tryBlock.getCodeUnitCount()); - Assert.assertEquals(1, tryBlock.getExceptionHandlers().size()); - Assert.assertEquals(null, tryBlock.getExceptionHandlers().get(0).getExceptionType()); - Assert.assertEquals(20, tryBlock.getExceptionHandlers().get(0).getHandlerCodeAddress()); - } - - private static void checkSwitchElement(SwitchElement element, int key, int offset) { - Assert.assertEquals(key, element.getKey()); - Assert.assertEquals(offset, element.getOffset()); - } - - public void testPackedSwitch() { - String text = - ".class public LFormat31t;\n" + - ".super Ljava/lang/Object;\n" + - ".source \"Format31t.smali\"" + - "\n" + - ".method public test_packed-switch()V\n" + - " .registers 1\n" + - " .annotation runtime Lorg/junit/Test;\n" + - " .end annotation\n" + - "\n" + - " const v0, 12\n" + - "\n" + - ":switch\n" + - " packed-switch v0, :PackedSwitch\n" + - "\n" + - ":Label10\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":Label11\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":Label12\n" + - " return-void\n" + - "\n" + - ":Label13\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":PackedSwitch\n" + - " .packed-switch 10\n" + - " :Label10\n" + - " :Label11\n" + - " :Label12\n" + - " :Label13\n" + - " .end packed-switch\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmalideaMethod method = new SmalideaMethod(smaliMethod); - - MethodImplementation impl = method.getImplementation(); - Assert.assertNotNull(impl); - - List instructions = Lists.newArrayList(impl.getInstructions()); - - PackedSwitchPayload packedSwitchPayload = (PackedSwitchPayload)instructions.get(9); - List switchElements = packedSwitchPayload.getSwitchElements(); - Assert.assertEquals(4, switchElements.size()); - - checkSwitchElement(switchElements.get(0), 10, 3); - checkSwitchElement(switchElements.get(1), 11, 7); - checkSwitchElement(switchElements.get(2), 12, 11); - checkSwitchElement(switchElements.get(3), 13, 12); - } - - public void testSparseSwitch() { - String text = - ".class public LFormat31t;\n" + - ".super Ljava/lang/Object;\n" + - ".source \"Format31t.smali\"" + - "\n" + - ".method public test_sparse-switch()V\n" + - " .registers 1\n" + - " .annotation runtime Lorg/junit/Test;\n" + - " .end annotation\n" + - "\n" + - " const v0, 13\n" + - "\n" + - ":switch\n" + - " sparse-switch v0, :SparseSwitch\n" + - "\n" + - ":Label10\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":Label20\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":Label15\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":Label13\n" + - " return-void\n" + - "\n" + - ":Label99\n" + - " invoke-static {}, Lorg/junit/Assert;->fail()V\n" + - " return-void\n" + - "\n" + - ":SparseSwitch\n" + - " .sparse-switch\n" + - " 10 -> :Label10\n" + - " 13 -> :Label13\n" + - " 15 -> :Label15\n" + - " 20 -> :Label20\n" + - " 99 -> :Label99\n" + - " .end sparse-switch\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmalideaMethod method = new SmalideaMethod(smaliMethod); - - MethodImplementation impl = method.getImplementation(); - Assert.assertNotNull(impl); - - List instructions = Lists.newArrayList(impl.getInstructions()); - - SparseSwitchPayload sparseSwitchPayload = (SparseSwitchPayload)instructions.get(11); - List switchElements = sparseSwitchPayload.getSwitchElements(); - Assert.assertEquals(5, switchElements.size()); - - checkSwitchElement(switchElements.get(0), 10, 3); - checkSwitchElement(switchElements.get(1), 13, 15); - checkSwitchElement(switchElements.get(2), 15, 11); - checkSwitchElement(switchElements.get(3), 20, 7); - checkSwitchElement(switchElements.get(4), 99, 16); - } - - public void testArrayData() { - String text = - ".class public LFormat31t;\n" + - ".super Ljava/lang/Object;\n" + - ".source \"Format31t.smali\"" + - "\n" + - ".method public test_fill-array-data()V\n" + - " .registers 3\n" + - " .annotation runtime Lorg/junit/Test;\n" + - " .end annotation\n" + - "\n" + - " const v0, 6\n" + - " new-array v0, v0, [I\n" + - " fill-array-data v0, :ArrayData\n" + - "\n" + - " const v1, 0\n" + - " aget v2, v0, v1\n" + - " const v1, 1\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " const v1, 1\n" + - " aget v2, v0, v1\n" + - " const v1, 2\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " const v1, 2\n" + - " aget v2, v0, v1\n" + - " const v1, 3\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " const v1, 3\n" + - " aget v2, v0, v1\n" + - " const v1, 4\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " const v1, 4\n" + - " aget v2, v0, v1\n" + - " const v1, 5\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " const v1, 5\n" + - " aget v2, v0, v1\n" + - " const v1, 6\n" + - " invoke-static {v1, v2}, LAssert;->assertEquals(II)V\n" + - "\n" + - " return-void\n" + - "\n" + - ":ArrayData\n" + - " .array-data 4\n" + - " 1 2 128 -256 65536 0x7fffffff\n" + - " .end array-data\n" + - ".end method"; - - SmaliFile file = (SmaliFile)myFixture.addFileToProject("my/pkg/blah.smali", text); - SmaliClass smaliClass = file.getPsiClass(); - SmaliMethod smaliMethod = smaliClass.getMethods()[0]; - - SmalideaMethod method = new SmalideaMethod(smaliMethod); - - MethodImplementation impl = method.getImplementation(); - Assert.assertNotNull(impl); - - List instructions = Lists.newArrayList(impl.getInstructions()); - - ArrayPayload arrayPayload = (ArrayPayload)instructions.get(28); - Assert.assertEquals(4, arrayPayload.getElementWidth()); - List elements = arrayPayload.getArrayElements(); - Assert.assertEquals(6, elements.size()); - - Assert.assertEquals(1L, elements.get(0).longValue()); - Assert.assertEquals(2L, elements.get(1).longValue()); - Assert.assertEquals(128L, elements.get(2)); - Assert.assertEquals(-256L, elements.get(3)); - Assert.assertEquals(65536L, elements.get(4)); - Assert.assertEquals(0x7fffffffL, elements.get(5)); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/ClassUsageTypeTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/ClassUsageTypeTest.java deleted file mode 100644 index 18a61941..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/ClassUsageTypeTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.jf.smalidea.findUsages; - -import com.intellij.usages.impl.rules.UsageType; - -public class ClassUsageTypeTest extends UsageTypeTest { - public ClassUsageTypeTest() { - super(new SmaliUsageTypeProvider()); - } - - public void testClassUsageTypes() throws Exception { - doTest("blah.smali", "" + - ".class public Lblah;\n" + - ".super Lblah;\n" + - ".implements Lblah;\n" + - "\n" + - ".annotation build Lblah;\n" + - " value = .subannotation Lblah;\n" + - " value = Lblah;\n" + - " .end subannotation\n" + - ".end annotation\n" + - "\n" + - ".field static public blah:Lblah; = Lblah;\n" + - "\n" + - ".method public blah(Lblah;)Lblah;\n" + - " .registers 2\n" + - " .local p0, \"this\":Lblah;\n" + - "\n" + - " :start\n" + - " iget-object v0, v0, Lblah;->blah:Lblah;\n" + - "\n" + - " invoke-virtual {v0}, Lblah;->blah(Lblah;)Lblah;\n" + - "\n" + - " instance-of v0, v0, Lblah;\n" + - " check-cast v0, Lblah;\n" + - " new-instance v0, Lblah;\n" + - " const-class v0, Lblah;\n" + - " throw-verification-error generic-error, Lblah;\n" + - "\n" + - " filled-new-array {v0, v0, v0, v0, v0}, Lblah;\n" + - " new-array v0, v0, Lblah;\n" + - " filled-new-array/range {v0}, Lblah;\n" + - " :end\n" + - "\n" + - " .catch Lblah; { :start .. :end } :handler\n" + - " :handler\n" + - " return-void\n" + - ".end method", - 1, SmaliUsageTypeProvider.CLASS_DECLARATION, - 2, UsageType.CLASS_EXTENDS_IMPLEMENTS_LIST, - 3, UsageType.CLASS_EXTENDS_IMPLEMENTS_LIST, - 4, UsageType.CLASS_FIELD_DECLARATION, - 5, UsageType.CLASS_METHOD_PARAMETER_DECLARATION, - 6, UsageType.CLASS_METHOD_RETURN_TYPE, - 7, UsageType.CLASS_LOCAL_VAR_DECLARATION, - 8, SmaliUsageTypeProvider.FIELD_DECLARING_TYPE_REFERENCE, - 9, SmaliUsageTypeProvider.FIELD_TYPE_REFERENCE, - 10, SmaliUsageTypeProvider.METHOD_DECLARING_TYPE_REFERENCE, - 11, SmaliUsageTypeProvider.METHOD_PARAM_REFERENCE, - 12, SmaliUsageTypeProvider.METHOD_RETURN_TYPE_REFERENCE, - 13, UsageType.CLASS_INSTANCE_OF, - 14, UsageType.CLASS_CAST_TO, - 15, UsageType.CLASS_NEW_OPERATOR, - 16, UsageType.CLASS_CLASS_OBJECT_ACCESS, - 17, SmaliUsageTypeProvider.VERIFICATION_ERROR, - 18, UsageType.CLASS_NEW_ARRAY, - 19, UsageType.CLASS_NEW_ARRAY, - 20, UsageType.CLASS_NEW_ARRAY, - 21, UsageType.CLASS_CATCH_CLAUSE_PARAMETER_DECLARATION, - 22, UsageType.ANNOTATION, - 23, UsageType.ANNOTATION, - 24, SmaliUsageTypeProvider.LITERAL, - 25, SmaliUsageTypeProvider.LITERAL); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FieldUsageTypeTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FieldUsageTypeTest.java deleted file mode 100644 index ffc2f207..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FieldUsageTypeTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.jf.smalidea.findUsages; - -import com.intellij.usages.impl.rules.UsageType; - -public class FieldUsageTypeTest extends UsageTypeTest { - public FieldUsageTypeTest() { - super(new SmaliUsageTypeProvider()); - } - - public void testFieldUsageTypes() throws Exception { - doTest("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - "\n" + - ".annotation runtime Lblah;\n" + - " element = Lblah;->blah:Lblah;\n" + - " element2 = .enum Lblah;->blah:Lblah;\n" + - ".end annotation\n" + - "\n" + - ".field public blah:Lblah;\n" + - "\n" + - ".method public blah(Lblah;)Lblah;\n" + - " .registers 2\n" + - "\n" + - " iget v0, v0, Lblah;->blah:Lblah;\n" + - " iget-object v0, v0, Lblah;->blah:Lblah;\n" + - " iget-byte v0, v0, Lblah;->blah:Lblah;\n" + - " iget-char v0, v0, Lblah;->blah:Lblah;\n" + - " iget-object v0, v0, Lblah;->blah:Lblah;\n" + - " iget-object-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " iget-short v0, v0, Lblah;->blah:Lblah;\n" + - " iget-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " iget-wide v0, v0, Lblah;->blah:Lblah;\n" + - " iget-wide-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " sget v0, Lblah;->blah:Lblah;\n" + - " sget-boolean v0, Lblah;->blah:Lblah;\n" + - " sget-byte v0, Lblah;->blah:Lblah;\n" + - " sget-char v0, Lblah;->blah:Lblah;\n" + - " sget-object v0, Lblah;->blah:Lblah;\n" + - " sget-object-volatile v0, Lblah;->blah:Lblah;\n" + - " sget-short v0, Lblah;->blah:Lblah;\n" + - " sget-volatile v0, Lblah;->blah:Lblah;\n" + - " sget-wide v0, Lblah;->blah:Lblah;\n" + - " sget-wide-volatile v0, Lblah;->blah:Lblah;\n" + - " \n" + - " iput v0, v0, Lblah;->blah:Lblah;\n" + - " iput-object v0, v0, Lblah;->blah:Lblah;\n" + - " iput-byte v0, v0, Lblah;->blah:Lblah;\n" + - " iput-char v0, v0, Lblah;->blah:Lblah;\n" + - " iput-object v0, v0, Lblah;->blah:Lblah;\n" + - " iput-object-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " iput-short v0, v0, Lblah;->blah:Lblah;\n" + - " iput-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " iput-wide v0, v0, Lblah;->blah:Lblah;\n" + - " iput-wide-volatile v0, v0, Lblah;->blah:Lblah;\n" + - " sput v0, Lblah;->blah:Lblah;\n" + - " sput-boolean v0, Lblah;->blah:Lblah;\n" + - " sput-byte v0, Lblah;->blah:Lblah;\n" + - " sput-char v0, Lblah;->blah:Lblah;\n" + - " sput-object v0, Lblah;->blah:Lblah;\n" + - // TODO: sput object volatile is no longer supported at default api level, - // thus disable his usage until Smalidea supports to define an api level - // " sput-object-volatile v0, Lblah;->blah:Lblah;\n" + - " sput-short v0, Lblah;->blah:Lblah;\n" + - " sput-volatile v0, Lblah;->blah:Lblah;\n" + - " sput-wide v0, Lblah;->blah:Lblah;\n" + - " sput-wide-volatile v0, Lblah;->blah:Lblah;\n" + - "\n" + - " throw-verification-error generic-error, Lblah;->blah:Lblah;\n" + - "\n" + - " return-void\n" + - ".end method\n", - 1, SmaliUsageTypeProvider.LITERAL, - 2, SmaliUsageTypeProvider.LITERAL, - 3, UsageType.READ, - 4, UsageType.READ, - 5, UsageType.READ, - 6, UsageType.READ, - 7, UsageType.READ, - 8, UsageType.READ, - 9, UsageType.READ, - 10, UsageType.READ, - 11, UsageType.READ, - 12, UsageType.READ, - 13, UsageType.READ, - 14, UsageType.READ, - 15, UsageType.READ, - 16, UsageType.READ, - 17, UsageType.READ, - 18, UsageType.READ, - 19, UsageType.READ, - 20, UsageType.READ, - 21, UsageType.READ, - 22, UsageType.READ, - 23, UsageType.WRITE, - 24, UsageType.WRITE, - 25, UsageType.WRITE, - 26, UsageType.WRITE, - 27, UsageType.WRITE, - 28, UsageType.WRITE, - 29, UsageType.WRITE, - 30, UsageType.WRITE, - 31, UsageType.WRITE, - 32, UsageType.WRITE, - 33, UsageType.WRITE, - 34, UsageType.WRITE, - 35, UsageType.WRITE, - 36, UsageType.WRITE, - 37, UsageType.WRITE, - // TODO: sput object volatile is no longer supported at default api level, - // thus disable his usage until Smalidea supports to define an api level - //38, UsageType.WRITE, - 39, UsageType.WRITE, - 40, UsageType.WRITE, - 41, UsageType.WRITE, - 42, UsageType.WRITE, - 43, SmaliUsageTypeProvider.VERIFICATION_ERROR); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindAnnotationElementUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FindAnnotationElementUsagesTest.java deleted file mode 100644 index ec889cca..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindAnnotationElementUsagesTest.java +++ /dev/null @@ -1,91 +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; - -public class FindAnnotationElementUsagesTest extends FindUsagesTest { - public void testSmaliUsageInSmaliFile() throws Exception { - addFile("AnnotationWithValues.smali", "" + - ".class public abstract interface annotation LAnnotationWithValues;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract intValue()I\n" + - ".end method\n" + - ".annotation system Ldalvik/annotation/AnnotationDefault;\n" + - " value = .subannotation LAnnotationWithValues;\n" + - " intValue = 4\n" + - " .end subannotation\n" + - ".end annotation"); - addFile("blarg.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".annotation runtime LAnnotationWithValues;\n" + - " intValue = 123\n" + - ".end annotation"); - doTest(); - } - - public void testJavaUsageInSmaliFile() throws Exception { - addFile("AnnotationWithValues.java", "" + - "\n" + - "public @interface AnnotationWithValues {\n" + - " int intValue() default 4;\n" + - "}"); - addFile("blarg.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".annotation runtime LAnnotationWithValues;\n" + - " intValue = 123\n" + - ".end annotation"); - doTest(); - } - - public void testSmaliUsageInJavaFile() throws Exception { - addFile("AnnotationWithValues.smali", "" + - ".class public abstract interface annotation LAnnotationWithValues;\n" + - ".super Ljava/lang/Object;\n" + - ".implements Ljava/lang/annotation/Annotation;\n" + - "\n" + - ".method public abstract intValue()I\n" + - ".end method\n" + - ".annotation system Ldalvik/annotation/AnnotationDefault;\n" + - " value = .subannotation LAnnotationWithValues;\n" + - " intValue = 4\n" + - " .end subannotation\n" + - ".end annotation"); - addFile("blarg.java", "" + - "\n" + - "@AnnotationWithValues(intValue=123)\n" + - "public class blarg {}"); - doTest(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindClassUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FindClassUsagesTest.java deleted file mode 100644 index 810ac5b1..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindClassUsagesTest.java +++ /dev/null @@ -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; - -public class FindClassUsagesTest extends FindUsagesTest { - public void testSmaliUsageInSmaliFile() throws Exception { - addFile("blah.smali", ".class public Lblah; .super Ljava/lang/Object;"); - addFile("blarg.smali", "" + - ".class public Lblarg; .super Ljava/lang/Object;\n" + - ".method public doSomething()V\n" + - " .registers 1\n" + - " new-instance v0, Lblah;\n" + - " invoke-direct {v0}, Lblah;->()V\n" + - " return-void\n" + - ".end method"); - doTest(); - } - - public void testSmaliUsageInJavaFile() throws Exception { - addFile("blah.smali", ".class public Lblah; .super Ljava/lang/Object;"); - addFile("blarg.java", "" + - "public class blarg {\n" + - " public void blargMethod() {\n" + - " new blah();\n" + - " }\n" + - "}"); - doTest(); - } - - public void testJavaUsageInSmaliFile() throws Exception { - addFile("blah.java", "" + - "public class blah {\n" + - " public blah blahMethod() {\n" + - " return new blah();\n" + - " }\n" + - "}"); - addFile("blarg.smali", "" + - ".class public Lblarg; .super Ljava/lang/Object;\n" + - ".method public doSomething()V\n" + - " .registers 1\n" + - " new-instance v0, Lblah;\n" + - " invoke-direct {v0}, Lblah;->()V\n" + - " return-void\n" + - ".end method"); - doTest(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindFieldUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FindFieldUsagesTest.java deleted file mode 100644 index 80c00547..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindFieldUsagesTest.java +++ /dev/null @@ -1,91 +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; - -public class FindFieldUsagesTest extends FindUsagesTest { - public void testSmaliUsageInSmaliFile() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".field blahField:I"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " iget v0, v0, Lblah;->blahField:I\n" + - ".end method"); - doTest(); - } - - public void testSmaliUsageInJavaFile() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".field blahField:I"); - addFile("blarg.java", "" + - "public class blarg {\n" + - " public int blargMethod() {\n" + - " blah b = new blah();\n" + - " return b.blahField;\n" + - " }\n" + - "}"); - doTest(); - } - - public void testJavaUsageInSmaliFile() throws Exception { - addFile("blah.java", "" + - "public class blah {\n" + - " public int blahField;\n" + - "}"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " iget v0, v0, Lblah;->blahField:I\n" + - ".end method"); - doTest(); - } - - public void testPrimitiveListMethod() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".field IIII:I"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " iget v0, v0, Lblah;->IIII:I\n" + - ".end method"); - doTest(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindMethodUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FindMethodUsagesTest.java deleted file mode 100644 index 311c9eef..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindMethodUsagesTest.java +++ /dev/null @@ -1,95 +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; - -public class FindMethodUsagesTest extends FindUsagesTest { - public void testSmaliUsageInSmaliFile() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blahMethod()V\n" + - ".end method"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " invoke-virtual {v0}, Lblah;->blahMethod()V\n" + - ".end method"); - doTest(); - } - - public void testSmaliUsageInJavaFile() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blahMethod()V\n" + - ".end method"); - addFile("blarg.java", "" + - "public class blarg {\n" + - " public void blargMethod() {\n" + - " blah b = new blah();\n" + - " b.blahMethod();\n" + - " }\n" + - "}"); - doTest(); - } - - public void testJavaUsageInSmaliFile() throws Exception { - addFile("blah.java", "" + - "public class blah {\n" + - " public void blahMethod() {\n" + - " }\n" + - "}"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " invoke-virtual {v0}, Lblah;->blahMethod()V\n" + - ".end method"); - doTest(); - } - - public void testPrimitiveListMethod() throws Exception { - addFile("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract IIII()V\n" + - ".end method"); - addFile("blarg.smali", "" + - ".class public Lblarg;\n" + - ".super Ljava/lang/Object;\n" + - ".method abstract blargMethod()V\n" + - " invoke-virtual {v0}, Lblah;->IIII()V\n" + - ".end method"); - doTest(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/FindUsagesTest.java deleted file mode 100644 index f4e2b0ff..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/FindUsagesTest.java +++ /dev/null @@ -1,195 +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.google.common.collect.Lists; -import com.intellij.codeInsight.TargetElementUtilBase; -import com.intellij.find.FindManager; -import com.intellij.find.findUsages.FindUsagesHandler; -import com.intellij.find.findUsages.FindUsagesManager; -import com.intellij.find.findUsages.FindUsagesOptions; -import com.intellij.find.impl.FindManagerImpl; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiReference; -import com.intellij.testFramework.PsiTestCase; -import com.intellij.usageView.UsageInfo; -import com.intellij.usages.PsiElementUsageTarget; -import com.intellij.usages.UsageTarget; -import com.intellij.usages.UsageTargetUtil; -import com.intellij.util.CommonProcessors; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; - -import java.util.Collection; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public abstract class FindUsagesTest extends PsiTestCase { - public static final String USAGE_TAG = ""; - public static final String REF_TAG = ""; - - private class TestFile { - @NotNull public final String fileName; - @NotNull public final String fileText; - @NotNull public final PsiFile psiFile; - - public TestFile(@NotNull String fileName, @NotNull String fileText) throws Exception { - this.fileName = fileName; - this.fileText = fileText; - this.psiFile = createFile(fileName, getText()); - } - - @NotNull - public String getText() { - return fileText.replace(REF_TAG, "").replace(USAGE_TAG, ""); - } - - public int getRefIndex() { - return fileText.replace(USAGE_TAG, "").indexOf(REF_TAG); - } - - public List getUsageIndices() { - Matcher matcher = Pattern.compile(USAGE_TAG).matcher(fileText.replace(REF_TAG, "")); - List matches = Lists.newArrayList(); - - int adjustment = 0; - while (matcher.find()) { - matches.add(matcher.start() - adjustment); - adjustment += USAGE_TAG.length(); - } - return matches; - } - } - - private List testFiles; - - @Override - public void setUp() throws Exception { - testFiles = Lists.newArrayList(); - super.setUp(); - } - - protected void addFile(String fileName, String fileText) throws Exception { - testFiles.add(new TestFile(fileName, fileText)); - } - - protected void doTest() { - - PsiReference reference = null; - PsiElement targetElement = null; - - for (TestFile testFile: testFiles) { - int refIndex = testFile.getRefIndex(); - if (refIndex != -1) { - PsiElement element = testFile.psiFile.findElementAt(refIndex); - - UsageTarget[] targets = UsageTargetUtil.findUsageTargets(element); - if (targets != null) { - for (UsageTarget target : targets) { - if (target instanceof PsiElementUsageTarget) { - targetElement = ((PsiElementUsageTarget)target).getElement(); - break; - } - } - } - - if (targetElement == null) { - reference = testFile.psiFile.findReferenceAt(refIndex); - if (reference != null) { - targetElement = reference.resolve(); - } else { - targetElement = TargetElementUtilBase.getInstance().getNamedElement( - testFile.psiFile.findElementAt(refIndex), 0); - } - } - break; - } - } - - Assert.assertNotNull(targetElement); - - Collection usages = findUsages(targetElement); - for (TestFile testFile: testFiles) { - assertUsages(testFile, usages); - } - } - - private void assertUsages(@NotNull TestFile testFile, @NotNull Collection usages) { - List fileUsages = Lists.newArrayList(); - for (UsageInfo usage: usages) { - if (usage.getFile().getName().equals(testFile.fileName)) { - fileUsages.add(usage); - } - } - - for (Integer usageIndex: testFile.getUsageIndices()) { - boolean found = false; - for (UsageInfo usage: fileUsages) { - int startOffset = usage.getElement().getNode().getStartOffset(); - int length = usage.getElement().getTextLength(); - - if (usageIndex >= startOffset && usageIndex < startOffset + length) { - fileUsages.remove(usage); - found = true; - break; - } - } - Assert.assertTrue(found); - } - Assert.assertEquals(0, fileUsages.size()); - } - - private Collection findUsages(@NotNull PsiElement element) { - FindUsagesManager findUsagesManager = - ((FindManagerImpl)FindManager.getInstance(getProject())).getFindUsagesManager(); - - FindUsagesHandler findUsagesHandler = - findUsagesManager.getFindUsagesHandler(element, false); - Assert.assertNotNull(findUsagesHandler); - - final FindUsagesOptions options = findUsagesHandler.getFindUsagesOptions(); - final CommonProcessors.CollectProcessor processor = - new CommonProcessors.CollectProcessor(); - - for (PsiElement primaryElement : findUsagesHandler.getPrimaryElements()) { - findUsagesHandler.processElementUsages(primaryElement, processor, options); - } - - for (PsiElement secondaryElement: findUsagesHandler.getSecondaryElements()) { - findUsagesHandler.processElementUsages(secondaryElement, processor, options); - } - - return processor.getResults(); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/HighlightLocalClassUsagesTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/HighlightLocalClassUsagesTest.java deleted file mode 100644 index ffec82cd..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/HighlightLocalClassUsagesTest.java +++ /dev/null @@ -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.findUsages; - -import com.google.common.collect.Lists; -import com.intellij.codeInsight.TargetElementUtilBase; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiReference; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.search.searches.ReferencesSearch; -import com.intellij.testFramework.PsiTestCase; -import org.junit.Assert; - -import java.util.List; - -public class HighlightLocalClassUsagesTest extends PsiTestCase { - public void testHighlightLocalClassUsage() throws Exception { - String fileText = "" + - ".class public Lblarg; .super Ljava/lang/Object;\n" + - ".method public doSomething()V\n" + - " .registers 1\n" + - " new-instance v0, Lblarg;\n" + - " invoke-direct {v0}, Lblah;->()V\n" + - " return-void\n" + - ".end method"; - - PsiFile file = createFile("blarg.smali", fileText.replace("", "")); - PsiElement target; - - int refIndex = fileText.indexOf(""); - PsiReference reference = file.findReferenceAt(refIndex); - if (reference != null) { - target = reference.resolve(); - } else { - target = TargetElementUtilBase.getInstance().getNamedElement( - file.findElementAt(refIndex), 0); - } - - final LocalSearchScope scope = new LocalSearchScope(file); - - List refs = Lists.newArrayList(ReferencesSearch.search(target, scope).findAll()); - Assert.assertEquals(2, refs.size()); - - Assert.assertEquals(file.findElementAt(refIndex).getTextOffset(), refs.get(0).getElement().getTextOffset()); - Assert.assertEquals(file.findElementAt(fileText.replaceFirst("", "").indexOf("")).getTextOffset(), - refs.get(1).getElement().getTextOffset()); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/MethodUsageTypeTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/MethodUsageTypeTest.java deleted file mode 100644 index eea3b156..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/MethodUsageTypeTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.jf.smalidea.findUsages; - -import com.intellij.usages.impl.rules.UsageType; - -public class MethodUsageTypeTest extends UsageTypeTest { - public MethodUsageTypeTest() { - super(new SmaliUsageTypeProvider()); - } - - public void testMethodUsageTypes() throws Exception { - doTest("blah.smali", "" + - ".class public Lblah;\n" + - ".super Ljava/lang/Object;\n" + - "\n" + - ".annotation runtime Lblah;\n" + - " element = Lblah;->blah()V;\n" + - ".end annotation\n" + - "\n" + - ".method public blah()V\n" + - " .registers 2\n" + - "\n" + - " invoke-direct {v0}, Lblah;->blah()V\n" + - " invoke-direct/empty {v0}, Lblah;->blah()V\n" + - " invoke-direct/range {v0}, Lblah;->blah()V\n" + - " invoke-interface {v0}, Lblah;->blah()V\n" + - " invoke-interface/range {v0}, Lblah;->blah()V\n" + - " invoke-object-init/range {v0}, Lblah;->blah()V\n" + - " invoke-static {v0}, Lblah;->blah()V\n" + - " invoke-static/range {v0}, Lblah;->blah()V\n" + - " invoke-super {v0}, Lblah;->blah()V\n" + - " invoke-super/range {v0}, Lblah;->blah()V\n" + - " invoke-virtual {v0}, Lblah;->blah()V\n" + - " invoke-virtual/range {v0}, Lblah;->blah()V\n" + - "\n" + - " throw-verification-error generic-error, Lblah;->blah()V\n" + - "\n" + - " return-void\n" + - ".end method\n", - 1, SmaliUsageTypeProvider.LITERAL, - 2, UsageType.UNCLASSIFIED, - 3, UsageType.UNCLASSIFIED, - 4, UsageType.UNCLASSIFIED, - 5, UsageType.UNCLASSIFIED, - 6, UsageType.UNCLASSIFIED, - 7, UsageType.UNCLASSIFIED, - 8, UsageType.UNCLASSIFIED, - 9, UsageType.UNCLASSIFIED, - 10, UsageType.UNCLASSIFIED, - 11, UsageType.UNCLASSIFIED, - 12, UsageType.UNCLASSIFIED, - 13, UsageType.UNCLASSIFIED, - 14, SmaliUsageTypeProvider.VERIFICATION_ERROR); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/findUsages/UsageTypeTest.java b/smalidea/src/test/java/org/jf/smalidea/findUsages/UsageTypeTest.java deleted file mode 100644 index 44c2f49f..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/findUsages/UsageTypeTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.jf.smalidea.findUsages; - -import com.google.common.collect.Maps; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; -import com.intellij.testFramework.PsiTestCase; -import com.intellij.usages.impl.rules.UsageType; -import com.intellij.usages.impl.rules.UsageTypeProvider; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public abstract class UsageTypeTest extends PsiTestCase { - // e.g. , , etc. - private static final Pattern REF_PATTERN = Pattern.compile("()"); - - @NotNull - private final UsageTypeProvider usageTypeProvider; - - public UsageTypeTest(@NotNull UsageTypeProvider usageTypeProvider) { - this.usageTypeProvider = usageTypeProvider; - } - - protected void doTest(@NotNull String fileName, @NotNull String text, @NotNull Object... expectedUsageTypes) - throws Exception { - Assert.assertTrue(expectedUsageTypes.length % 2 == 0); - - Map expectedUsageTypesMap = Maps.newHashMap(); - for (int i=0; i refIndexMap = getRefIndexes(text); - - for (Map.Entry entry: refIndexMap.entrySet()) { - int refId = entry.getKey(); - int index = entry.getValue(); - - PsiReference reference = psiFile.getFirstChild().findReferenceAt(index); - Assert.assertNotNull(reference); - if (reference instanceof PsiMultiReference) { - // If there are multiple reference parents, the default seems to be the last one, - // i.e. the highest parent. We actually want the lowest one here. - reference = ((PsiMultiReference) reference).getReferences()[0]; - } - - UsageType usageType = usageTypeProvider.getUsageType(reference.getElement()); - Assert.assertNotNull(usageType); - Assert.assertSame(expectedUsageTypesMap.get(refId), usageType); - expectedUsageTypesMap.remove(refId); - } - Assert.assertTrue(expectedUsageTypesMap.isEmpty()); - } - - @NotNull - private Map getRefIndexes(@NotNull String text) { - Matcher m = REF_PATTERN.matcher(text); - int correction = 0; - Map refIndexes = new HashMap(); - while (m.find()) { - int refId = Integer.parseInt(m.group(2)); - refIndexes.put(refId, m.start() - correction); - correction += m.end() - m.start(); - } - return refIndexes; - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/util/NameUtilsTest.java b/smalidea/src/test/java/org/jf/smalidea/util/NameUtilsTest.java deleted file mode 100644 index 60aef8ba..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/util/NameUtilsTest.java +++ /dev/null @@ -1,87 +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.util; - -import junit.framework.Assert; -import org.junit.Test; - -public class NameUtilsTest { - - @Test - public void testConversions() { - testConversion("boolean", "Z"); - testConversion("byte", "B"); - testConversion("char", "C"); - testConversion("short", "S"); - testConversion("int", "I"); - testConversion("long", "J"); - testConversion("float", "F"); - testConversion("double", "D"); - - testConversion("blah", "Lblah;"); - testConversion("my.blah", "Lmy/blah;"); - - testConversion("boolean[]", "[Z"); - testConversion("byte[]", "[B"); - testConversion("char[]", "[C"); - testConversion("short[]", "[S"); - testConversion("int[]", "[I"); - testConversion("long[]", "[J"); - testConversion("float[]", "[F"); - testConversion("double[]", "[D"); - - testConversion("blah[]", "[Lblah;"); - testConversion("my.blah[]", "[Lmy/blah;"); - - testConversion("boolean[][][][]", "[[[[Z"); - testConversion("byte[][][][]", "[[[[B"); - testConversion("char[][][][]", "[[[[C"); - testConversion("short[][][][]", "[[[[S"); - testConversion("int[][][][]", "[[[[I"); - testConversion("long[][][][]", "[[[[J"); - testConversion("float[][][][]", "[[[[F"); - testConversion("double[][][][]", "[[[[D"); - - testConversion("blah[][][][]", "[[[[Lblah;"); - testConversion("my.blah[][][][]", "[[[[Lmy/blah;"); - } - - private static void testConversion(String javaType, String smaliType) { - Assert.assertEquals(javaType, NameUtils.smaliToJavaType(smaliType)); - Assert.assertEquals(smaliType, NameUtils.javaToSmaliType(javaType)); - } - - public void testShortNameFromQualifiedName() { - Assert.assertEquals("blah", NameUtils.shortNameFromQualifiedName("org.blah.blah")); - Assert.assertEquals("blah", NameUtils.shortNameFromQualifiedName("blah")); - } -} diff --git a/smalidea/src/test/java/org/jf/smalidea/util/StringUtilsTest.java b/smalidea/src/test/java/org/jf/smalidea/util/StringUtilsTest.java deleted file mode 100644 index 4c5a9a68..00000000 --- a/smalidea/src/test/java/org/jf/smalidea/util/StringUtilsTest.java +++ /dev/null @@ -1,49 +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.util; - -import org.junit.Assert; -import org.junit.Test; - -public class StringUtilsTest { - @Test - public void testStringUtilsBasic() throws Exception { - String parsedString = StringUtils.parseQuotedString("\"abcd\""); - Assert.assertEquals("abcd", parsedString); - } - - @Test - public void testStringUtilsQuotedChars() throws Exception { - String parsedString = StringUtils.parseQuotedString("\"a\\\\b\\nc\\uabcdd\""); - Assert.assertEquals("a\\b\nc\uabcdd", parsedString); - } -} diff --git a/smalidea/testData/Empty.smalidea b/smalidea/testData/Empty.smalidea deleted file mode 100644 index e69de29b..00000000 diff --git a/smalidea/testData/Empty.txt b/smalidea/testData/Empty.txt deleted file mode 100644 index 91655095..00000000 --- a/smalidea/testData/Empty.txt +++ /dev/null @@ -1,8 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - PsiErrorElement:required (...)+ loop did not match anything at input '' - \ No newline at end of file diff --git a/smalidea/testData/FieldAnnotations.smalidea b/smalidea/testData/FieldAnnotations.smalidea deleted file mode 100644 index 37167693..00000000 --- a/smalidea/testData/FieldAnnotations.smalidea +++ /dev/null @@ -1,15 +0,0 @@ -.field public blah:I - -.field public blah2:I - .annotation runtime Lblah; - .end annotation - .annotation runtime Lblah; - .end annotation -.end field - -.field public blah2:I - -.annotation runtime Lblah; -.end annotation -.annotation runtime Lblah; -.end annotation diff --git a/smalidea/testData/FieldAnnotations.txt b/smalidea/testData/FieldAnnotations.txt deleted file mode 100644 index 80332e59..00000000 --- a/smalidea/testData/FieldAnnotations.txt +++ /dev/null @@ -1,91 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(COLON)(':') - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace('\n\n') - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah2') - PsiElement(COLON)(':') - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace('\n ') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n ') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n') - PsiElement(END_FIELD_DIRECTIVE)('.end field') - PsiWhiteSpace('\n\n') - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah2') - PsiElement(COLON)(':') - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace('\n\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') \ No newline at end of file diff --git a/smalidea/testData/InvalidAnnotation.smalidea b/smalidea/testData/InvalidAnnotation.smalidea deleted file mode 100644 index 9825e293..00000000 --- a/smalidea/testData/InvalidAnnotation.smalidea +++ /dev/null @@ -1,19 +0,0 @@ -.annotation .blah Lblah; -.end annotation - -.annotation runtime .blah -.end annotation - -.annotation runtime Lblah; - blah .blah .blah -.end annotation - -.annotation runtime Lblah; - blah = .blah .blah -.end annotation - -.annotation runtime Lblah; - blah = .subannotation Lblah2; - blah = "blah" - .blah -.end annotation \ No newline at end of file diff --git a/smalidea/testData/InvalidAnnotation.txt b/smalidea/testData/InvalidAnnotation.txt deleted file mode 100644 index 3799410f..00000000 --- a/smalidea/testData/InvalidAnnotation.txt +++ /dev/null @@ -1,108 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting ANNOTATION_VISIBILITY - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting CLASS_DESCRIPTOR - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - PsiElement(ANNOTATION_ELEMENT) - PsiElement(ANNOTATION_ELEMENT_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting EQUAL - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - PsiElement(ANNOTATION_ELEMENT) - PsiElement(ANNOTATION_ELEMENT_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiElement(EQUAL)('=') - PsiWhiteSpace(' ') - PsiErrorElement:no viable alternative at input '.blah' - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n\n') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - PsiElement(ANNOTATION_ELEMENT) - PsiElement(ANNOTATION_ELEMENT_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiElement(EQUAL)('=') - PsiWhiteSpace(' ') - SmaliAnnotation(ANNOTATION) - PsiElement(SUBANNOTATION_DIRECTIVE)('.subannotation') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah2;') - PsiWhiteSpace('\n ') - PsiElement(ANNOTATION_PARAMETER_LIST) - PsiElement(ANNOTATION_ELEMENT) - PsiElement(ANNOTATION_ELEMENT_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiElement(EQUAL)('=') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(STRING_LITERAL)('"blah"') - PsiWhiteSpace('\n ') - PsiErrorElement:mismatched input '.blah' expecting END_SUBANNOTATION_DIRECTIVE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective.smalidea b/smalidea/testData/InvalidClassDirective.smalidea deleted file mode 100644 index 9f6b5ba5..00000000 --- a/smalidea/testData/InvalidClassDirective.smalidea +++ /dev/null @@ -1 +0,0 @@ -.class \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective.txt b/smalidea/testData/InvalidClassDirective.txt deleted file mode 100644 index e9f89c0d..00000000 --- a/smalidea/testData/InvalidClassDirective.txt +++ /dev/null @@ -1,12 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - SmaliModifierList(MODIFIER_LIST) - - PsiErrorElement:mismatched input '' expecting CLASS_DESCRIPTOR - \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective2.smalidea b/smalidea/testData/InvalidClassDirective2.smalidea deleted file mode 100644 index ee4d27e5..00000000 --- a/smalidea/testData/InvalidClassDirective2.smalidea +++ /dev/null @@ -1,2 +0,0 @@ -.class -.super Ljava/lang/Object; \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective2.txt b/smalidea/testData/InvalidClassDirective2.txt deleted file mode 100644 index 6f36abe8..00000000 --- a/smalidea/testData/InvalidClassDirective2.txt +++ /dev/null @@ -1,15 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace('\n') - SmaliModifierList(MODIFIER_LIST) - - PsiErrorElement:extraneous input '.super' expecting CLASS_DESCRIPTOR - PsiElement(SUPER_DIRECTIVE)('.super') - PsiWhiteSpace(' ') - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;') \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective3.smalidea b/smalidea/testData/InvalidClassDirective3.smalidea deleted file mode 100644 index fd5d3608..00000000 --- a/smalidea/testData/InvalidClassDirective3.smalidea +++ /dev/null @@ -1 +0,0 @@ -.class public .class Ltest; \ No newline at end of file diff --git a/smalidea/testData/InvalidClassDirective3.txt b/smalidea/testData/InvalidClassDirective3.txt deleted file mode 100644 index ed98ac64..00000000 --- a/smalidea/testData/InvalidClassDirective3.txt +++ /dev/null @@ -1,16 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiErrorElement:extraneous input '.class' expecting CLASS_DESCRIPTOR - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - PsiElement(CLASS_DESCRIPTOR)('Ltest;') \ No newline at end of file diff --git a/smalidea/testData/InvalidEnumLiteral.smalidea b/smalidea/testData/InvalidEnumLiteral.smalidea deleted file mode 100644 index 8853cc3a..00000000 --- a/smalidea/testData/InvalidEnumLiteral.smalidea +++ /dev/null @@ -1 +0,0 @@ -.field public static blah:Ljava/lang/Object; = .enum Lblah;->blah .blah Lblah; \ No newline at end of file diff --git a/smalidea/testData/InvalidEnumLiteral.txt b/smalidea/testData/InvalidEnumLiteral.txt deleted file mode 100644 index b2acd87d..00000000 --- a/smalidea/testData/InvalidEnumLiteral.txt +++ /dev/null @@ -1,38 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(ACCESS_SPEC)('static') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(COLON)(':') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;') - PsiWhiteSpace(' ') - PsiElement(FIELD_INITIALIZER) - PsiElement(EQUAL)('=') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(ENUM_DIRECTIVE)('.enum') - PsiWhiteSpace(' ') - PsiElement(FIELD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting COLON - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') \ No newline at end of file diff --git a/smalidea/testData/InvalidField.smalidea b/smalidea/testData/InvalidField.smalidea deleted file mode 100644 index 8eb11200..00000000 --- a/smalidea/testData/InvalidField.smalidea +++ /dev/null @@ -1 +0,0 @@ -.field \ No newline at end of file diff --git a/smalidea/testData/InvalidField.txt b/smalidea/testData/InvalidField.txt deleted file mode 100644 index 99aa29ee..00000000 --- a/smalidea/testData/InvalidField.txt +++ /dev/null @@ -1,13 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiErrorElement:no viable alternative at input '' - \ No newline at end of file diff --git a/smalidea/testData/InvalidField2.smalidea b/smalidea/testData/InvalidField2.smalidea deleted file mode 100644 index 8de7a3a6..00000000 --- a/smalidea/testData/InvalidField2.smalidea +++ /dev/null @@ -1 +0,0 @@ -.field public blah .blah \ No newline at end of file diff --git a/smalidea/testData/InvalidField2.txt b/smalidea/testData/InvalidField2.txt deleted file mode 100644 index b3e8227b..00000000 --- a/smalidea/testData/InvalidField2.txt +++ /dev/null @@ -1,17 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting COLON - PsiElement(BAD_CHARACTER)('.blah') \ No newline at end of file diff --git a/smalidea/testData/InvalidField3.smalidea b/smalidea/testData/InvalidField3.smalidea deleted file mode 100644 index 9de31427..00000000 --- a/smalidea/testData/InvalidField3.smalidea +++ /dev/null @@ -1,3 +0,0 @@ -.field public public:I -.blah -.end field \ No newline at end of file diff --git a/smalidea/testData/InvalidField3.txt b/smalidea/testData/InvalidField3.txt deleted file mode 100644 index 508df467..00000000 --- a/smalidea/testData/InvalidField3.txt +++ /dev/null @@ -1,22 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(ACCESS_SPEC)('public') - PsiElement(COLON)(':') - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace('\n') - PsiErrorElement:Unexpected tokens - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_FIELD_DIRECTIVE)('.end field') \ No newline at end of file diff --git a/smalidea/testData/InvalidField4.smalidea b/smalidea/testData/InvalidField4.smalidea deleted file mode 100644 index 11a8cb20..00000000 --- a/smalidea/testData/InvalidField4.smalidea +++ /dev/null @@ -1 +0,0 @@ -.field public blah:.blah \ No newline at end of file diff --git a/smalidea/testData/InvalidField4.txt b/smalidea/testData/InvalidField4.txt deleted file mode 100644 index 4eedd931..00000000 --- a/smalidea/testData/InvalidField4.txt +++ /dev/null @@ -1,17 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliField(FIELD) - PsiElement(FIELD_DIRECTIVE)('.field') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(COLON)(':') - PsiErrorElement:no viable alternative at input '.blah' - PsiElement(BAD_CHARACTER)('.blah') \ No newline at end of file diff --git a/smalidea/testData/InvalidInstruction.smalidea b/smalidea/testData/InvalidInstruction.smalidea deleted file mode 100644 index 0960b886..00000000 --- a/smalidea/testData/InvalidInstruction.smalidea +++ /dev/null @@ -1,31 +0,0 @@ -.method blah()V -.registers 1 -invoke-virtual .blah v0}, Lblah;->blah()V -.end method - -.method blah2()V -.registers 1 -invoke-virtual {v1, v2} .blah Lblah;->blah()V -.end method - -.method blah3()V - .array-data 4 - 1 - 2 - .blah -.end method - -.method blah4()V - .packed-switch 1 - :blah - :blah2 - .blah -.end method - -.method blah5()V - .sparse-switch - 1 -> :blah - 3 -> :blah2 - 5 -> :blah3 - .blah -.end method \ No newline at end of file diff --git a/smalidea/testData/InvalidInstruction.txt b/smalidea/testData/InvalidInstruction.txt deleted file mode 100644 index 76502573..00000000 --- a/smalidea/testData/InvalidInstruction.txt +++ /dev/null @@ -1,236 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting OPEN_BRACE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah2') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v1') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v2') - PsiElement(CLOSE_BRACE)('}') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting COMMA - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah3') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(INSTRUCTION) - PsiElement(ARRAY_DATA_DIRECTIVE)('.array-data') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('4') - PsiWhiteSpace('\n ') - PsiElement(ARRAY_DATA_ELEMENT) - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n ') - PsiElement(ARRAY_DATA_ELEMENT) - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('2') - PsiWhiteSpace('\n ') - PsiErrorElement:mismatched input '.blah' expecting END_ARRAY_DATA_DIRECTIVE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah4') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(INSTRUCTION) - PsiElement(PACKED_SWITCH_DIRECTIVE)('.packed-switch') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n ') - PsiElement(PACKED_SWITCH_ELEMENT) - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace('\n ') - PsiElement(PACKED_SWITCH_ELEMENT) - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah2') - PsiWhiteSpace('\n ') - PsiErrorElement:mismatched input '.blah' expecting END_PACKED_SWITCH_DIRECTIVE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah5') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(INSTRUCTION) - PsiElement(SPARSE_SWITCH_DIRECTIVE)('.sparse-switch') - PsiWhiteSpace('\n ') - PsiElement(SPARSE_SWITCH_ELEMENT) - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace('\n ') - PsiElement(SPARSE_SWITCH_ELEMENT) - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('3') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah2') - PsiWhiteSpace('\n ') - PsiElement(SPARSE_SWITCH_ELEMENT) - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('5') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah3') - PsiWhiteSpace('\n ') - PsiErrorElement:mismatched input '.blah' expecting END_SPARSE_SWITCH_DIRECTIVE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/InvalidLocal.smalidea b/smalidea/testData/InvalidLocal.smalidea deleted file mode 100644 index 48bcd081..00000000 --- a/smalidea/testData/InvalidLocal.smalidea +++ /dev/null @@ -1,7 +0,0 @@ -.method public blah()V - .local v0, -.end method - -.method public blah()V - .local v0,"": -.end method \ No newline at end of file diff --git a/smalidea/testData/InvalidLocal.txt b/smalidea/testData/InvalidLocal.txt deleted file mode 100644 index b639c46f..00000000 --- a/smalidea/testData/InvalidLocal.txt +++ /dev/null @@ -1,66 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(LOCAL_DEBUG_STATEMENT) - PsiElement(LOCAL_DIRECTIVE)('.local') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(COMMA)(',') - PsiErrorElement:no viable alternative at input '.end method' - - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(LOCAL_DEBUG_STATEMENT) - PsiElement(LOCAL_DIRECTIVE)('.local') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(COMMA)(',') - PsiElement(LITERAL) - PsiElement(STRING_LITERAL)('""') - PsiElement(COLON)(':') - PsiErrorElement:no viable alternative at input '.end method' - - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod.smalidea b/smalidea/testData/InvalidMethod.smalidea deleted file mode 100644 index 57245e9f..00000000 --- a/smalidea/testData/InvalidMethod.smalidea +++ /dev/null @@ -1,4 +0,0 @@ -.class Ltest; -.super Ljava/lang/Object; - -.method .blah \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod.txt b/smalidea/testData/InvalidMethod.txt deleted file mode 100644 index 421e084f..00000000 --- a/smalidea/testData/InvalidMethod.txt +++ /dev/null @@ -1,33 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ltest;') - PsiWhiteSpace('\n') - PsiElement(SUPER_STATEMENT) - PsiElement(SUPER_DIRECTIVE)('.super') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiErrorElement:no viable alternative at input '.blah' - PsiElement(BAD_CHARACTER)('.blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - SmaliMethodParamList(METHOD_PARAM_LIST) - \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod2.smalidea b/smalidea/testData/InvalidMethod2.smalidea deleted file mode 100644 index d5301430..00000000 --- a/smalidea/testData/InvalidMethod2.smalidea +++ /dev/null @@ -1,6 +0,0 @@ -.class Ltest; -.super Ljava/lang/Object; - -.method blah - -.method \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod2.txt b/smalidea/testData/InvalidMethod2.txt deleted file mode 100644 index 1a3a1cdb..00000000 --- a/smalidea/testData/InvalidMethod2.txt +++ /dev/null @@ -1,49 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ltest;') - PsiWhiteSpace('\n') - PsiElement(SUPER_STATEMENT) - PsiElement(SUPER_DIRECTIVE)('.super') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace('\n\n') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiErrorElement:mismatched input '.method' expecting OPEN_PAREN - - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiErrorElement:missing END_METHOD_DIRECTIVE at '.method' - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiErrorElement:no viable alternative at input '' - - SmaliMethodPrototype(METHOD_PROTOTYPE) - SmaliMethodParamList(METHOD_PARAM_LIST) - \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod3.smalidea b/smalidea/testData/InvalidMethod3.smalidea deleted file mode 100644 index 24e66b6f..00000000 --- a/smalidea/testData/InvalidMethod3.smalidea +++ /dev/null @@ -1,11 +0,0 @@ -.method blah()V -.end - - - -.method return-object()V -.registers 0 - - - -.method \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod3.txt b/smalidea/testData/InvalidMethod3.txt deleted file mode 100644 index ce143718..00000000 --- a/smalidea/testData/InvalidMethod3.txt +++ /dev/null @@ -1,63 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiErrorElement:mismatched input '.end' expecting END_METHOD_DIRECTIVE - PsiElement(BAD_CHARACTER)('.end') - PsiWhiteSpace('\n\n\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(INSTRUCTION_FORMAT11x)('return-object') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('0') - PsiErrorElement:missing END_METHOD_DIRECTIVE at '.method' - - PsiWhiteSpace('\n\n\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiErrorElement:no viable alternative at input '' - - SmaliMethodPrototype(METHOD_PROTOTYPE) - SmaliMethodParamList(METHOD_PARAM_LIST) - \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod4.smalidea b/smalidea/testData/InvalidMethod4.smalidea deleted file mode 100644 index ff86bf37..00000000 --- a/smalidea/testData/InvalidMethod4.smalidea +++ /dev/null @@ -1,8 +0,0 @@ -.method blah .blah )V -.end method - -.method blah(I .blah V -.end method - -.method blah())V -.end method \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod4.txt b/smalidea/testData/InvalidMethod4.txt deleted file mode 100644 index aae80654..00000000 --- a/smalidea/testData/InvalidMethod4.txt +++ /dev/null @@ -1,73 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiErrorElement:mismatched input '.blah' expecting OPEN_PAREN - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - SmaliMethodParameter(METHOD_PARAMETER) - SmaliModifierList(MODIFIER_LIST) - - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting CLOSE_PAREN - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiErrorElement:no viable alternative at input ')' - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/InvalidMethodReference.smalidea b/smalidea/testData/InvalidMethodReference.smalidea deleted file mode 100644 index 8ee6d79a..00000000 --- a/smalidea/testData/InvalidMethodReference.smalidea +++ /dev/null @@ -1,24 +0,0 @@ -.method blah()V -.registers 1 -invoke-virtual {v0}, .blah-> -.end method - -.method blah2()V -.registers 1 -invoke-virtual {v0}, Lblah;.blah -.end method - -.method blah3()V -.registers 1 -invoke-virtual {v0}, Lblah;->blah .blah )V -.end method - -.method blah4()V -.registers 1 -invoke-virtual {v0}, Lblah;->blah(I .blah V -.end method - -.method blah5()V -.registers 1 -invoke-virtual {v0}, Lblah;->blah())V -.end method diff --git a/smalidea/testData/InvalidMethodReference.txt b/smalidea/testData/InvalidMethodReference.txt deleted file mode 100644 index 490d38cf..00000000 --- a/smalidea/testData/InvalidMethodReference.txt +++ /dev/null @@ -1,241 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiErrorElement:no viable alternative at input '.blah-' - PsiElement(BAD_CHARACTER)('.blah-') - PsiElement(BAD_CHARACTER)('>') - PsiWhiteSpace('\n') - PsiElement(MEMBER_NAME) - - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah2') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiErrorElement:mismatched input '.blah' expecting ARROW - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace('\n') - PsiElement(MEMBER_NAME) - - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah3') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting OPEN_PAREN - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah4') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - PsiElement(PRIMITIVE_TYPE) - PsiElement(PRIMITIVE_TYPE)('I') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting CLOSE_PAREN - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah5') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(REGISTERS_STATEMENT) - PsiElement(REGISTERS_DIRECTIVE)('.registers') - PsiWhiteSpace(' ') - PsiElement(LITERAL) - PsiElement(POSITIVE_INTEGER_LITERAL)('1') - PsiWhiteSpace('\n') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT35c_METHOD)('invoke-virtual') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiErrorElement:no viable alternative at input ')' - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/InvalidParameter.smalidea b/smalidea/testData/InvalidParameter.smalidea deleted file mode 100644 index 014299fd..00000000 --- a/smalidea/testData/InvalidParameter.smalidea +++ /dev/null @@ -1,10 +0,0 @@ -.method public blah()V - .param v0, "blah" - .a -.end method - -.method public blah()V - .param v0, "blah" - .annotation runtime Lblah; .end annotation - . -.end method \ No newline at end of file diff --git a/smalidea/testData/InvalidParameter.txt b/smalidea/testData/InvalidParameter.txt deleted file mode 100644 index 27168efe..00000000 --- a/smalidea/testData/InvalidParameter.txt +++ /dev/null @@ -1,85 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(PARAMETER_STATEMENT) - PsiElement(PARAMETER_DIRECTIVE)('.param') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(LOCAL_NAME) - PsiElement(LITERAL) - PsiElement(STRING_LITERAL)('"blah"') - PsiWhiteSpace('\n ') - PsiErrorElement:no viable alternative at input '.a' - PsiElement(BAD_CHARACTER)('.a') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(PARAMETER_STATEMENT) - PsiElement(PARAMETER_DIRECTIVE)('.param') - PsiWhiteSpace(' ') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(LOCAL_NAME) - PsiElement(LITERAL) - PsiElement(STRING_LITERAL)('"blah"') - PsiWhiteSpace('\n ') - SmaliAnnotation(ANNOTATION) - PsiElement(ANNOTATION_DIRECTIVE)('.annotation') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_VISIBILITY)('runtime') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace(' ') - PsiElement(ANNOTATION_PARAMETER_LIST) - - PsiElement(END_ANNOTATION_DIRECTIVE)('.end annotation') - PsiWhiteSpace('\n ') - PsiErrorElement:no viable alternative at input '.' - PsiElement(BAD_CHARACTER)('.') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/MissingDotDot.smalidea b/smalidea/testData/MissingDotDot.smalidea deleted file mode 100644 index 5e8e6b6e..00000000 --- a/smalidea/testData/MissingDotDot.smalidea +++ /dev/null @@ -1,9 +0,0 @@ -.method public blah()V - invoke-virtual/range {v0 v1}, Lblah;->blah()V - - invoke-virtual/range {v0 .blah v1}, Lblah;->blah()V - - .catch Ljava/lang/Exception; { :blah1 :blah2 } :blah3 - - .catch Ljava/lang/Exception; { :blah1 .blah :blah2 } :blah3 -.end method \ No newline at end of file diff --git a/smalidea/testData/MissingDotDot.txt b/smalidea/testData/MissingDotDot.txt deleted file mode 100644 index 53a1eccf..00000000 --- a/smalidea/testData/MissingDotDot.txt +++ /dev/null @@ -1,126 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - PsiElement(ACCESS_SPEC)('public') - PsiWhiteSpace(' ') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n ') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT3rc_METHOD)('invoke-virtual/range') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiWhiteSpace(' ') - PsiErrorElement:extraneous input 'v1' expecting CLOSE_BRACE - PsiElement(REGISTER)('v1') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n\n ') - PsiElement(INSTRUCTION) - PsiElement(INSTRUCTION_FORMAT3rc_METHOD)('invoke-virtual/range') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiElement(REGISTER_REFERENCE) - PsiElement(REGISTER)('v0') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting CLOSE_BRACE - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(REGISTER)('v1') - PsiElement(CLOSE_BRACE)('}') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(METHOD_REFERENCE) - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiElement(ARROW)('->') - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - PsiElement(OPEN_PAREN)('(') - PsiElement(METHOD_REFERENCE_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n\n ') - PsiElement(CATCH_STATEMENT) - PsiElement(CATCH_DIRECTIVE)('.catch') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Exception;') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah1') - PsiErrorElement:missing DOTDOT at ':' - - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah2') - PsiWhiteSpace(' ') - PsiElement(CLOSE_BRACE)('}') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah3') - PsiWhiteSpace('\n\n ') - PsiElement(CATCH_STATEMENT) - PsiElement(CATCH_DIRECTIVE)('.catch') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Exception;') - PsiWhiteSpace(' ') - PsiElement(OPEN_BRACE)('{') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah1') - PsiWhiteSpace(' ') - PsiErrorElement:mismatched input '.blah' expecting DOTDOT - PsiElement(BAD_CHARACTER)('.blah') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah2') - PsiWhiteSpace(' ') - PsiElement(CLOSE_BRACE)('}') - PsiWhiteSpace(' ') - PsiElement(LABEL_REFERENCE) - PsiElement(COLON)(':') - PsiElement(SIMPLE_NAME)('blah3') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/ParamListInvalidParameter.smalidea b/smalidea/testData/ParamListInvalidParameter.smalidea deleted file mode 100644 index f9a8728c..00000000 --- a/smalidea/testData/ParamListInvalidParameter.smalidea +++ /dev/null @@ -1,5 +0,0 @@ -.class Lblah; -.super Ljava/lang/Object; - -.method blah(f) -.end method \ No newline at end of file diff --git a/smalidea/testData/ParamListInvalidParameter.txt b/smalidea/testData/ParamListInvalidParameter.txt deleted file mode 100644 index ea94d463..00000000 --- a/smalidea/testData/ParamListInvalidParameter.txt +++ /dev/null @@ -1,38 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(SUPER_STATEMENT) - PsiElement(SUPER_DIRECTIVE)('.super') - PsiWhiteSpace(' ') - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;') - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiErrorElement:extraneous input 'f' expecting CLOSE_PAREN - PsiElement(SIMPLE_NAME)('f') - PsiElement(CLOSE_PAREN)(')') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/SuperClassInvalidSyntax.smalidea b/smalidea/testData/SuperClassInvalidSyntax.smalidea deleted file mode 100644 index cea9d102..00000000 --- a/smalidea/testData/SuperClassInvalidSyntax.smalidea +++ /dev/null @@ -1,2 +0,0 @@ -.class Lblah; -.super \ No newline at end of file diff --git a/smalidea/testData/SuperClassInvalidSyntax.txt b/smalidea/testData/SuperClassInvalidSyntax.txt deleted file mode 100644 index 316041cd..00000000 --- a/smalidea/testData/SuperClassInvalidSyntax.txt +++ /dev/null @@ -1,18 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(SUPER_STATEMENT) - PsiElement(SUPER_DIRECTIVE)('.super') - PsiErrorElement:mismatched input '' expecting CLASS_DESCRIPTOR - \ No newline at end of file diff --git a/smalidea/testData/SuperClassInvalidSyntax2.smalidea b/smalidea/testData/SuperClassInvalidSyntax2.smalidea deleted file mode 100644 index 8793e8cb..00000000 --- a/smalidea/testData/SuperClassInvalidSyntax2.smalidea +++ /dev/null @@ -1,5 +0,0 @@ -.class Lblah; -.super - -.method blah()V -.end method \ No newline at end of file diff --git a/smalidea/testData/SuperClassInvalidSyntax2.txt b/smalidea/testData/SuperClassInvalidSyntax2.txt deleted file mode 100644 index 348fab47..00000000 --- a/smalidea/testData/SuperClassInvalidSyntax2.txt +++ /dev/null @@ -1,37 +0,0 @@ -smali.FILE - SmaliClass(CLASS) - SmaliExtendsList(EXTENDS_LIST) - - SmaliImplementsList(IMPLEMENTS_LIST) - - SmaliClassStatement(CLASS_STATEMENT) - PsiElement(CLASS_DIRECTIVE)('.class') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(CLASS_TYPE) - PsiElement(CLASS_DESCRIPTOR)('Lblah;') - PsiWhiteSpace('\n') - PsiElement(SUPER_STATEMENT) - PsiElement(SUPER_DIRECTIVE)('.super') - PsiErrorElement:missing CLASS_DESCRIPTOR at '.method' - - PsiWhiteSpace('\n\n') - SmaliMethod(METHOD) - SmaliThrowsList(THROWS_LIST) - - PsiElement(METHOD_DIRECTIVE)('.method') - PsiWhiteSpace(' ') - SmaliModifierList(MODIFIER_LIST) - - PsiElement(MEMBER_NAME) - PsiElement(SIMPLE_NAME)('blah') - SmaliMethodPrototype(METHOD_PROTOTYPE) - PsiElement(OPEN_PAREN)('(') - SmaliMethodParamList(METHOD_PARAM_LIST) - - PsiElement(CLOSE_PAREN)(')') - PsiElement(VOID_TYPE) - PsiElement(VOID_TYPE)('V') - PsiWhiteSpace('\n') - PsiElement(END_METHOD_DIRECTIVE)('.end method') \ No newline at end of file diff --git a/smalidea/testData/classMove/basicFromNoPackage/after/my/blah.smali b/smalidea/testData/classMove/basicFromNoPackage/after/my/blah.smali deleted file mode 100644 index dc4522cc..00000000 --- a/smalidea/testData/classMove/basicFromNoPackage/after/my/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lmy/blah; -.super Lmy/blah; -.implements Lmy/blah; - -.annotation build Lmy/blah; - value = .subannotation Lmy/blah; - value = Lmy/blah; - .end subannotation -.end annotation - -.field static public blah:Lmy/blah; = Lmy/blah; - -.method public blah(Lmy/blah;)Lmy/blah; - .registers 2 - .local p0, "this":Lmy/blah; - - :start - iget-object v0, v0, Lmy/blah;->blah:Lmy/blah; - - invoke-virtual {v0}, Lmy/blah;->blah(Lmy/blah;)Lmy/blah; - - instance-of v0, v0, Lmy/blah; - check-cast v0, Lmy/blah; - new-instance v0, Lmy/blah; - const-class v0, Lmy/blah; - throw-verification-error generic-error, Lmy/blah; - - filled-new-array {v0, v0, v0, v0, v0}, Lmy/blah; - new-array v0, v0, Lmy/blah; - filled-new-array/range {v0}, Lmy/blah; - :end - - .catch Lmy/blah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classMove/basicFromNoPackage/before/blah.smali b/smalidea/testData/classMove/basicFromNoPackage/before/blah.smali deleted file mode 100644 index 0a72c715..00000000 --- a/smalidea/testData/classMove/basicFromNoPackage/before/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lblah; -.super Lblah; -.implements Lblah; - -.annotation build Lblah; - value = .subannotation Lblah; - value = Lblah; - .end subannotation -.end annotation - -.field static public blah:Lblah; = Lblah; - -.method public blah(Lblah;)Lblah; - .registers 2 - .local p0, "this":Lblah; - - :start - iget-object v0, v0, Lblah;->blah:Lblah; - - invoke-virtual {v0}, Lblah;->blah(Lblah;)Lblah; - - instance-of v0, v0, Lblah; - check-cast v0, Lblah; - new-instance v0, Lblah; - const-class v0, Lblah; - throw-verification-error generic-error, Lblah; - - filled-new-array {v0, v0, v0, v0, v0}, Lblah; - new-array v0, v0, Lblah; - filled-new-array/range {v0}, Lblah; - :end - - .catch Lblah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classMove/basicToNoPackage/after/blah.smali b/smalidea/testData/classMove/basicToNoPackage/after/blah.smali deleted file mode 100644 index 0a72c715..00000000 --- a/smalidea/testData/classMove/basicToNoPackage/after/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lblah; -.super Lblah; -.implements Lblah; - -.annotation build Lblah; - value = .subannotation Lblah; - value = Lblah; - .end subannotation -.end annotation - -.field static public blah:Lblah; = Lblah; - -.method public blah(Lblah;)Lblah; - .registers 2 - .local p0, "this":Lblah; - - :start - iget-object v0, v0, Lblah;->blah:Lblah; - - invoke-virtual {v0}, Lblah;->blah(Lblah;)Lblah; - - instance-of v0, v0, Lblah; - check-cast v0, Lblah; - new-instance v0, Lblah; - const-class v0, Lblah; - throw-verification-error generic-error, Lblah; - - filled-new-array {v0, v0, v0, v0, v0}, Lblah; - new-array v0, v0, Lblah; - filled-new-array/range {v0}, Lblah; - :end - - .catch Lblah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classMove/basicToNoPackage/after/my/placeholder.smali b/smalidea/testData/classMove/basicToNoPackage/after/my/placeholder.smali deleted file mode 100644 index 02813447..00000000 --- a/smalidea/testData/classMove/basicToNoPackage/after/my/placeholder.smali +++ /dev/null @@ -1,2 +0,0 @@ -.class public Lmy/placeholder; -.super Ljava/lang/Object; \ No newline at end of file diff --git a/smalidea/testData/classMove/basicToNoPackage/before/my/blah.smali b/smalidea/testData/classMove/basicToNoPackage/before/my/blah.smali deleted file mode 100644 index dc4522cc..00000000 --- a/smalidea/testData/classMove/basicToNoPackage/before/my/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lmy/blah; -.super Lmy/blah; -.implements Lmy/blah; - -.annotation build Lmy/blah; - value = .subannotation Lmy/blah; - value = Lmy/blah; - .end subannotation -.end annotation - -.field static public blah:Lmy/blah; = Lmy/blah; - -.method public blah(Lmy/blah;)Lmy/blah; - .registers 2 - .local p0, "this":Lmy/blah; - - :start - iget-object v0, v0, Lmy/blah;->blah:Lmy/blah; - - invoke-virtual {v0}, Lmy/blah;->blah(Lmy/blah;)Lmy/blah; - - instance-of v0, v0, Lmy/blah; - check-cast v0, Lmy/blah; - new-instance v0, Lmy/blah; - const-class v0, Lmy/blah; - throw-verification-error generic-error, Lmy/blah; - - filled-new-array {v0, v0, v0, v0, v0}, Lmy/blah; - new-array v0, v0, Lmy/blah; - filled-new-array/range {v0}, Lmy/blah; - :end - - .catch Lmy/blah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classMove/basicToNoPackage/before/my/placeholder.smali b/smalidea/testData/classMove/basicToNoPackage/before/my/placeholder.smali deleted file mode 100644 index 02813447..00000000 --- a/smalidea/testData/classMove/basicToNoPackage/before/my/placeholder.smali +++ /dev/null @@ -1,2 +0,0 @@ -.class public Lmy/placeholder; -.super Ljava/lang/Object; \ No newline at end of file diff --git a/smalidea/testData/classRename/basicNoPackage/after/blah2.smali b/smalidea/testData/classRename/basicNoPackage/after/blah2.smali deleted file mode 100644 index 112b106e..00000000 --- a/smalidea/testData/classRename/basicNoPackage/after/blah2.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lblah2; -.super Lblah2; -.implements Lblah2; - -.annotation build Lblah2; - value = .subannotation Lblah2; - value = Lblah2; - .end subannotation -.end annotation - -.field static public blah:Lblah2; = Lblah2; - -.method public blah(Lblah2;)Lblah2; - .registers 2 - .local p0, "this":Lblah2; - - :start - iget-object v0, v0, Lblah2;->blah:Lblah2; - - invoke-virtual {v0}, Lblah2;->blah(Lblah2;)Lblah2; - - instance-of v0, v0, Lblah2; - check-cast v0, Lblah2; - new-instance v0, Lblah2; - const-class v0, Lblah2; - throw-verification-error generic-error, Lblah2; - - filled-new-array {v0, v0, v0, v0, v0}, Lblah2; - new-array v0, v0, Lblah2; - filled-new-array/range {v0}, Lblah2; - :end - - .catch Lblah2; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classRename/basicNoPackage/before/blah.smali b/smalidea/testData/classRename/basicNoPackage/before/blah.smali deleted file mode 100644 index 0a72c715..00000000 --- a/smalidea/testData/classRename/basicNoPackage/before/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lblah; -.super Lblah; -.implements Lblah; - -.annotation build Lblah; - value = .subannotation Lblah; - value = Lblah; - .end subannotation -.end annotation - -.field static public blah:Lblah; = Lblah; - -.method public blah(Lblah;)Lblah; - .registers 2 - .local p0, "this":Lblah; - - :start - iget-object v0, v0, Lblah;->blah:Lblah; - - invoke-virtual {v0}, Lblah;->blah(Lblah;)Lblah; - - instance-of v0, v0, Lblah; - check-cast v0, Lblah; - new-instance v0, Lblah; - const-class v0, Lblah; - throw-verification-error generic-error, Lblah; - - filled-new-array {v0, v0, v0, v0, v0}, Lblah; - new-array v0, v0, Lblah; - filled-new-array/range {v0}, Lblah; - :end - - .catch Lblah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classRename/basicWithPackage/after/my/blah2.smali b/smalidea/testData/classRename/basicWithPackage/after/my/blah2.smali deleted file mode 100644 index f08d5137..00000000 --- a/smalidea/testData/classRename/basicWithPackage/after/my/blah2.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lmy/blah2; -.super Lmy/blah2; -.implements Lmy/blah2; - -.annotation build Lmy/blah2; - value = .subannotation Lmy/blah2; - value = Lmy/blah2; - .end subannotation -.end annotation - -.field static public blah:Lmy/blah2; = Lmy/blah2; - -.method public blah(Lmy/blah2;)Lmy/blah2; - .registers 2 - .local p0, "this":Lmy/blah2; - - :start - iget-object v0, v0, Lmy/blah2;->blah:Lmy/blah2; - - invoke-virtual {v0}, Lmy/blah2;->blah(Lmy/blah2;)Lmy/blah2; - - instance-of v0, v0, Lmy/blah2; - check-cast v0, Lmy/blah2; - new-instance v0, Lmy/blah2; - const-class v0, Lmy/blah2; - throw-verification-error generic-error, Lmy/blah2; - - filled-new-array {v0, v0, v0, v0, v0}, Lmy/blah2; - new-array v0, v0, Lmy/blah2; - filled-new-array/range {v0}, Lmy/blah2; - :end - - .catch Lmy/blah2; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/classRename/basicWithPackage/before/my/blah.smali b/smalidea/testData/classRename/basicWithPackage/before/my/blah.smali deleted file mode 100644 index dc4522cc..00000000 --- a/smalidea/testData/classRename/basicWithPackage/before/my/blah.smali +++ /dev/null @@ -1,36 +0,0 @@ -.class public Lmy/blah; -.super Lmy/blah; -.implements Lmy/blah; - -.annotation build Lmy/blah; - value = .subannotation Lmy/blah; - value = Lmy/blah; - .end subannotation -.end annotation - -.field static public blah:Lmy/blah; = Lmy/blah; - -.method public blah(Lmy/blah;)Lmy/blah; - .registers 2 - .local p0, "this":Lmy/blah; - - :start - iget-object v0, v0, Lmy/blah;->blah:Lmy/blah; - - invoke-virtual {v0}, Lmy/blah;->blah(Lmy/blah;)Lmy/blah; - - instance-of v0, v0, Lmy/blah; - check-cast v0, Lmy/blah; - new-instance v0, Lmy/blah; - const-class v0, Lmy/blah; - throw-verification-error generic-error, Lmy/blah; - - filled-new-array {v0, v0, v0, v0, v0}, Lmy/blah; - new-array v0, v0, Lmy/blah; - filled-new-array/range {v0}, Lmy/blah; - :end - - .catch Lmy/blah; { :start .. :end } :handler - :handler - return-void -.end method \ No newline at end of file diff --git a/smalidea/testData/fieldRename/fieldRename/after/blah.smali b/smalidea/testData/fieldRename/fieldRename/after/blah.smali deleted file mode 100644 index e2a23690..00000000 --- a/smalidea/testData/fieldRename/fieldRename/after/blah.smali +++ /dev/null @@ -1,59 +0,0 @@ -.class public Lblah; -.super Ljava/lang/Object; - -.annotation runtime Lblah; - element = Lblah;->blort:Lblah; - element2 = .enum Lblah;->blort:Lblah; -.end annotation - -.field public blort:Lblah; - -.method public blah(Lblah;)Lblah; - .registers 2 - - iget v0, v0, Lblah;->blort:Lblah; - iget-object v0, v0, Lblah;->blort:Lblah; - iget-byte v0, v0, Lblah;->blort:Lblah; - iget-char v0, v0, Lblah;->blort:Lblah; - iget-object v0, v0, Lblah;->blort:Lblah; - iget-object-volatile v0, v0, Lblah;->blort:Lblah; - iget-short v0, v0, Lblah;->blort:Lblah; - iget-volatile v0, v0, Lblah;->blort:Lblah; - iget-wide v0, v0, Lblah;->blort:Lblah; - iget-wide-volatile v0, v0, Lblah;->blort:Lblah; - sget v0, Lblah;->blort:Lblah; - sget-boolean v0, Lblah;->blort:Lblah; - sget-byte v0, Lblah;->blort:Lblah; - sget-char v0, Lblah;->blort:Lblah; - sget-object v0, Lblah;->blort:Lblah; - sget-object-volatile v0, Lblah;->blort:Lblah; - sget-short v0, Lblah;->blort:Lblah; - sget-volatile v0, Lblah;->blort:Lblah; - sget-wide v0, Lblah;->blort:Lblah; - sget-wide-volatile v0, Lblah;->blort:Lblah; - - iput v0, v0, Lblah;->blort:Lblah; - iput-object v0, v0, Lblah;->blort:Lblah; - iput-byte v0, v0, Lblah;->blort:Lblah; - iput-char v0, v0, Lblah;->blort:Lblah; - iput-object v0, v0, Lblah;->blort:Lblah; - iput-object-volatile v0, v0, Lblah;->blort:Lblah; - iput-short v0, v0, Lblah;->blort:Lblah; - iput-volatile v0, v0, Lblah;->blort:Lblah; - iput-wide v0, v0, Lblah;->blort:Lblah; - iput-wide-volatile v0, v0, Lblah;->blort:Lblah; - sput v0, Lblah;->blort:Lblah; - sput-boolean v0, Lblah;->blort:Lblah; - sput-byte v0, Lblah;->blort:Lblah; - sput-char v0, Lblah;->blort:Lblah; - sput-object v0, Lblah;->blort:Lblah; - sput-object-volatile v0, Lblah;->blort:Lblah; - sput-short v0, Lblah;->blort:Lblah; - sput-volatile v0, Lblah;->blort:Lblah; - sput-wide v0, Lblah;->blort:Lblah; - sput-wide-volatile v0, Lblah;->blort:Lblah; - - throw-verification-error generic-error, Lblah;->blort:Lblah; - - return-void -.end method diff --git a/smalidea/testData/fieldRename/fieldRename/before/blah.smali b/smalidea/testData/fieldRename/fieldRename/before/blah.smali deleted file mode 100644 index ab4dc6c2..00000000 --- a/smalidea/testData/fieldRename/fieldRename/before/blah.smali +++ /dev/null @@ -1,59 +0,0 @@ -.class public Lblah; -.super Ljava/lang/Object; - -.annotation runtime Lblah; - element = Lblah;->blah:Lblah; - element2 = .enum Lblah;->blah:Lblah; -.end annotation - -.field public blah:Lblah; - -.method public blah(Lblah;)Lblah; - .registers 2 - - iget v0, v0, Lblah;->blah:Lblah; - iget-object v0, v0, Lblah;->blah:Lblah; - iget-byte v0, v0, Lblah;->blah:Lblah; - iget-char v0, v0, Lblah;->blah:Lblah; - iget-object v0, v0, Lblah;->blah:Lblah; - iget-object-volatile v0, v0, Lblah;->blah:Lblah; - iget-short v0, v0, Lblah;->blah:Lblah; - iget-volatile v0, v0, Lblah;->blah:Lblah; - iget-wide v0, v0, Lblah;->blah:Lblah; - iget-wide-volatile v0, v0, Lblah;->blah:Lblah; - sget v0, Lblah;->blah:Lblah; - sget-boolean v0, Lblah;->blah:Lblah; - sget-byte v0, Lblah;->blah:Lblah; - sget-char v0, Lblah;->blah:Lblah; - sget-object v0, Lblah;->blah:Lblah; - sget-object-volatile v0, Lblah;->blah:Lblah; - sget-short v0, Lblah;->blah:Lblah; - sget-volatile v0, Lblah;->blah:Lblah; - sget-wide v0, Lblah;->blah:Lblah; - sget-wide-volatile v0, Lblah;->blah:Lblah; - - iput v0, v0, Lblah;->blah:Lblah; - iput-object v0, v0, Lblah;->blah:Lblah; - iput-byte v0, v0, Lblah;->blah:Lblah; - iput-char v0, v0, Lblah;->blah:Lblah; - iput-object v0, v0, Lblah;->blah:Lblah; - iput-object-volatile v0, v0, Lblah;->blah:Lblah; - iput-short v0, v0, Lblah;->blah:Lblah; - iput-volatile v0, v0, Lblah;->blah:Lblah; - iput-wide v0, v0, Lblah;->blah:Lblah; - iput-wide-volatile v0, v0, Lblah;->blah:Lblah; - sput v0, Lblah;->blah:Lblah; - sput-boolean v0, Lblah;->blah:Lblah; - sput-byte v0, Lblah;->blah:Lblah; - sput-char v0, Lblah;->blah:Lblah; - sput-object v0, Lblah;->blah:Lblah; - sput-object-volatile v0, Lblah;->blah:Lblah; - sput-short v0, Lblah;->blah:Lblah; - sput-volatile v0, Lblah;->blah:Lblah; - sput-wide v0, Lblah;->blah:Lblah; - sput-wide-volatile v0, Lblah;->blah:Lblah; - - throw-verification-error generic-error, Lblah;->blah:Lblah; - - return-void -.end method diff --git a/smalidea/testData/methodRename/methodRename/after/blah.smali b/smalidea/testData/methodRename/methodRename/after/blah.smali deleted file mode 100644 index 2343699e..00000000 --- a/smalidea/testData/methodRename/methodRename/after/blah.smali +++ /dev/null @@ -1,27 +0,0 @@ -.class public Lblah; -.super Ljava/lang/Object; - -.annotation runtime Lblah; - element = Lblah;->blort()V; -.end annotation - -.method public blort()V - .registers 2 - - invoke-direct {v0}, Lblah;->blort()V - invoke-direct/empty {v0}, Lblah;->blort()V - invoke-direct/range {v0}, Lblah;->blort()V - invoke-interface {v0}, Lblah;->blort()V - invoke-interface/range {v0}, Lblah;->blort()V - invoke-object-init/range {v0}, Lblah;->blort()V - invoke-static {v0}, Lblah;->blort()V - invoke-static/range {v0}, Lblah;->blort()V - invoke-super {v0}, Lblah;->blort()V - invoke-super/range {v0}, Lblah;->blort()V - invoke-virtual {v0}, Lblah;->blort()V - invoke-virtual/range {v0}, Lblah;->blort()V - - throw-verification-error generic-error, Lblah;->blort()V - - return-void -.end method diff --git a/smalidea/testData/methodRename/methodRename/before/blah.smali b/smalidea/testData/methodRename/methodRename/before/blah.smali deleted file mode 100644 index 9a800dc5..00000000 --- a/smalidea/testData/methodRename/methodRename/before/blah.smali +++ /dev/null @@ -1,27 +0,0 @@ -.class public Lblah; -.super Ljava/lang/Object; - -.annotation runtime Lblah; - element = Lblah;->blah()V; -.end annotation - -.method public blah()V - .registers 2 - - invoke-direct {v0}, Lblah;->blah()V - invoke-direct/empty {v0}, Lblah;->blah()V - invoke-direct/range {v0}, Lblah;->blah()V - invoke-interface {v0}, Lblah;->blah()V - invoke-interface/range {v0}, Lblah;->blah()V - invoke-object-init/range {v0}, Lblah;->blah()V - invoke-static {v0}, Lblah;->blah()V - invoke-static/range {v0}, Lblah;->blah()V - invoke-super {v0}, Lblah;->blah()V - invoke-super/range {v0}, Lblah;->blah()V - invoke-virtual {v0}, Lblah;->blah()V - invoke-virtual/range {v0}, Lblah;->blah()V - - throw-verification-error generic-error, Lblah;->blah()V - - return-void -.end method