score:1
Accepted answer
one solution will be not using the offset logic at all. you can generalise the solution by using a node parent check.
here is a sample code:
public boolean visit(stringliteral stringliteral) {
// check if parent is a method inovacation.
if (stringliteral.getparent().getnodetype() == astnode.method_invocation) {
// get the parent method inovacation.
methodinvocation minode = (methodinvocation) stringliteral.getparent();
//to do: null and empty check on argument list.
// check if is the special method and this is the 1st argument
if (minode.getname().tostring().equals("specialmethod")
&& minode.arguments().get(0).tostring().equals(stringliteral.tostring())) {
system.out.println("found it : " + stringliteral.tostring());
}
}
return true;
}
Source: stackoverflow.com
Related Query
- How to get down to StringLiterals with Eclipse AST?
- How do I get Eclipse to resolve classes generated with Maven 2?
- How to get gdb working with Eclipse CDT under windows (fails to find source code)
- How do I get Eclipse to switch to SVN view on synchronize with repository?
- How to get angular2 to work in eclipse with typescript
- How to get Eclipse SWT Browser component running on Ubuntu 11.04 (Natty Narwhal) with Webkit?
- How can I get Eclipse work with Maven and SVN correctly?
- How to get started with a bare-bones Eclipse + PyDev
- How to get Eclipse Warnings when compiling with maven?
- When you get a stack trace in Eclipse with SDK classes in the stack, how can you see the SDK sources?
- When developing an Eclipse plugin, how to get access to the project's Java Model and AST root node?
- Eclipse -> Run as -> Run on server - How to get it to work with JBoss?
- How to get Eclipse tools working nicely with JSP?
- Build with Maven in Eclipse Photon - How to get console colours?
- In Eclipse 3.5 (and with the Aptana plugins), how do I get a view that I can use to show my project, including "dot" files?
- In Eclipse with m2e, how to get "Quick Javadoc" (F2) to display for Maven dependencies?
- How do you get the Eclipse Package Explorer to show files whose names begins with a . (period)?
- How to install TBB on Windows and get it work with Eclipse
- How to track down JAR with corrupt JAR Index that cause InvalidJarIndexException in Tomcat in Eclipse
- How to get Two Eclipse Dynamic Web Projects Set up on WebLogic with a Different Port for Each Project?
- How can I get Eclipse PHP-IDE to collapse #regions with PHP like Visual Studio does with C#?
- How to get screenshot with Android phone bezel in Eclipse AVD?
- How to get Eclipse and IntelliJ working together in an existing project of IntelliJ (optional with changes in source directly transferred)
- how to get neo4j Graph database in GWT with eclipse running
- How to get CardLayout implemented properly with Eclipse WindowBuilder?
- How to get Spring Explorer view in Eclipse 2018-12 with Spring Tool Suite 4 installed?
- How can I get eclipse to create Run Configurations for junit with extra parameters?
- How to Get JSF 2.0 Working with Eclipse 3.5 and JBoss 5.1
- How do I get OpenGL/GLUT working with Eclipse IDE (cocoa 64 bit) using C++ and on Snow Leopard
- How to get a truly blank vanilla app with eclipse
More Query from same tag
- How can I recreate an Instagram like scroll where the post information remains at the top until the next post reaches the top on Android?
- "Indentation size" disabled in Eclipse XML plugin
- cannot resolve "org.h2.tools.Server"?
- Read static file in a Eclipse plugin
- adding the android environment to eclipse
- Running python command line interpreter inside PyDev
- How to display different labels for the same action in the a Project Explorer context menu item depending on the nature of the project selected?
- Can I addCommand a file and commit it?how?
- How to add mysql JDBC driver to Eclipse so it can be used by SQL Explorer?
- How to change font size in message box in eclipse RCP?
- Error java.lang.runtimeexception view is not a sliding drawer
- No Launcher Activity found ! in android
- Pydev: error initializing console
- Eclipse RSE and xdebug - will this work?
- Eclipse null analysis: The expression of type int needs unchecked conversion to conform to '@Nonnull Integer'
- This FragmentManager should be recycled after use with #recylce()
- Context sensitive menu in eclipse editor
- Error creating Runnable jar in eclipse
- How to increase content assist tooltip size in Eclipse / PDT
- Replacing Jar files within Tomcat in Eclipse
- How to select repository for staging view in Eclipse Luna 4.4?
- Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException
- configure.h file and assembbler error in FFT from FFMPEG
- Android Wake On Lan in Java
- Getting JBoss Seam to work with Eclipse
- Cannot create Maven Project in eclipse
- Cannot verify method calls with mockito in eclipse
- I am getting incompatitble debugger version in eclipse while using pydev
- How to make keyboard configuration as close as possible to Visual Studio or Eclipse in XCode
- Connect Eclipse RSE with remote Linux server using public key attained from Amazon ec2