Skip to main content
Jump to: navigation, search

Difference between revisions of "VIATRA/Query/UserDocumentation/PureWhitelist"

< VIATRA‎ | Query
(Update to VIATRA Query 1.2)
Line 1: Line 1:
 
By default, check()/eval() constraints do not support calling arbitrary Java methods, since they are generally assumed to be impure. However, if you have a pure method and want to call it in these types of constraints, you have two options:  
 
By default, check()/eval() constraints do not support calling arbitrary Java methods, since they are generally assumed to be impure. However, if you have a pure method and want to call it in these types of constraints, you have two options:  
 
* if it is implemented by you, annotate it with the <tt>@Pure</tt> annotation of Xbase (<tt>org.eclipse.xtext.xbase.lib.Pure</tt>)
 
* if it is implemented by you, annotate it with the <tt>@Pure</tt> annotation of Xbase (<tt>org.eclipse.xtext.xbase.lib.Pure</tt>)
* if it comes from a third-party library, register it via the <tt>org.eclipse.incquery.patternlanguage.purewhitelist</tt> extension point
+
* if it comes from a third-party library, register it via the <tt>org.eclipse.viatra.query.patternlanguage.purewhitelist</tt> extension point
 
Some standard library methods are marked as pure by default, including:
 
Some standard library methods are marked as pure by default, including:
 
* <tt>java.lang.Math</tt>
 
* <tt>java.lang.Math</tt>
 
* <tt>java.lang.String</tt>
 
* <tt>java.lang.String</tt>

Revision as of 06:05, 22 March 2016

By default, check()/eval() constraints do not support calling arbitrary Java methods, since they are generally assumed to be impure. However, if you have a pure method and want to call it in these types of constraints, you have two options:

  • if it is implemented by you, annotate it with the @Pure annotation of Xbase (org.eclipse.xtext.xbase.lib.Pure)
  • if it comes from a third-party library, register it via the org.eclipse.viatra.query.patternlanguage.purewhitelist extension point

Some standard library methods are marked as pure by default, including:

  • java.lang.Math
  • java.lang.String

Copyright © Eclipse Foundation, Inc. All Rights Reserved.