Skip to content

Commit

Permalink
ren docs after repo move
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
  • Loading branch information
cdietrich committed Nov 28, 2024
1 parent 72e7e89 commit 733043f
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 277 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.xtend.doc/contents/101_gettingstarted.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1 id="getting-started">Hello World</h1>
}
</code></pre>

<p>The only surprising fact in the generated Java code may be the referenced library class <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/InputOutput.java">InputOutput</a>. It is part of the runtime library and a nice utility that is quite handy when used in expressions.</p>
<p>The only surprising fact in the generated Java code may be the referenced library class <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/InputOutput.java">InputOutput</a>. It is part of the runtime library and a nice utility that is quite handy when used in expressions.</p>

<p>You can put an Xtend class into a source folder of any Java project within Eclipse or any Maven project. If the project is not yet configured properly, Eclipse will complain about the missing library. The xtend.lib has to be on the class path. The IDE will provide a quick fix to add it.</p>

Expand Down
10 changes: 5 additions & 5 deletions org.eclipse.xtend.doc/contents/102_moviesexample.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ <h2 id="parsing-the-data">Parsing The Data</h2>
<pre><code class="language-xtend">import static extension com.google.common.io.CharStreams.*
</code></pre>

<p><a href="https://guava.dev/releases/30.1-jre/api/docs//com/google/common/io/CharStreams.html"><code>CharStreams.readLines(Reader)</code></a> returns a <a href="https://docs.oracle.com/javase/11/docs/api/java/util/List.html"><code>List&lt;String&gt;</code></a> on which we call another extension method <code>map</code>. This one is defined in the runtime library (<a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java">ListExtensions.map(…)</a>) and is automatically imported and therefore available on all lists. The <code>map</code> extension expects a function as a parameter. It basically invokes that function for each value in the list and returns another list containing the results of the function invocations. Actually this mapping is performed lazily so if you never access the values of the result list, the mapping function is never executed.</p>
<p><a href="https://guava.dev/releases/30.1-jre/api/docs//com/google/common/io/CharStreams.html"><code>CharStreams.readLines(Reader)</code></a> returns a <a href="https://docs.oracle.com/javase/11/docs/api/java/util/List.html"><code>List&lt;String&gt;</code></a> on which we call another extension method <code>map</code>. This one is defined in the runtime library (<a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java">ListExtensions.map(…)</a>) and is automatically imported and therefore available on all lists. The <code>map</code> extension expects a function as a parameter. It basically invokes that function for each value in the list and returns another list containing the results of the function invocations. Actually this mapping is performed lazily so if you never access the values of the result list, the mapping function is never executed.</p>

<p>Function objects are created using <a href="203_xtend_expressions.html#lambdas">lambda expressions</a> (the code in squared brackets). Within the lambda we process a single line from the text file and turn it into a movie by splitting the string using two whitespace characters as the separator. On the result of the split operation, the method <code>iterator()</code> is invoked. As you might know <a href="https://docs.oracle.com/javase/11/docs/api/java/lang/String.html">String.split(String)</a> returns a string array (<code>String[]</code>), which Xtend <a href="201_types.html#conversion-rules">auto-converts to a list</a> when we call <a href="https://docs.oracle.com/javase/11/docs/api/java/lang/Iterable.html"><code>Iterable.iterator()</code></a> on it.</p>

<pre><code class="language-xtend">val segments = line.split(' ').iterator
</code></pre>

<p>Now we use the iterator to create an instance of <code>Movie</code> for each String that it yields. The data type conversion (e.g. <code>String</code> to <code>int</code>) is done by calling <a href="203_xtend_expressions.html#static-access">static methods</a> from the wrapper types. The rest of the <a href="https://docs.oracle.com/javase/11/docs/api/java/lang/Iterable.html">Iterable</a> is turned into a set of categories. Therefore, the extension method <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java"><code>IteratorExtensions.toSet(Iterator&lt;T&gt;)</code></a> is invoked on the iterator to consume its remaining values.</p>
<p>Now we use the iterator to create an instance of <code>Movie</code> for each String that it yields. The data type conversion (e.g. <code>String</code> to <code>int</code>) is done by calling <a href="203_xtend_expressions.html#static-access">static methods</a> from the wrapper types. The rest of the <a href="https://docs.oracle.com/javase/11/docs/api/java/lang/Iterable.html">Iterable</a> is turned into a set of categories. Therefore, the extension method <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java"><code>IteratorExtensions.toSet(Iterator&lt;T&gt;)</code></a> is invoked on the iterator to consume its remaining values.</p>

<pre><code class="language-xtend">return new Movie (
segments.next,
Expand Down Expand Up @@ -124,7 +124,7 @@ <h3 id="question1">Question 1 : What Is The Number Of Action Movies?</h3>
<pre><code class="language-xtend">movies.filter[ categories.contains('Action') ].size
</code></pre>

<p>Eventually we call <code>size</code> on the resulting iterable which is an extension method, too. It is defined in the utility class <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java">IterableExtensions</a>.</p>
<p>Eventually we call <code>size</code> on the resulting iterable which is an extension method, too. It is defined in the utility class <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java">IterableExtensions</a>.</p>

<h3 id="question2">Question 2 : What Is The Year The Best Movie From The 80’s Was Released?</h3>

Expand All @@ -134,9 +134,9 @@ <h3 id="question2">Question 2 : What Is The Year The Best Movie From The 80’s
}
</code></pre>

<p>Here we <code>filter</code> for all movies whose year is included in the range from 1980 to 1989 (the 80’s). The <code>..</code> operator is again an extension defined in <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java">IntegerExtensions</a> and returns an instance of <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerRange.java">IntegerRange</a>. Operator overloading is explained in <a href="203_xtend_expressions.html#operators">section</a>.</p>
<p>Here we <code>filter</code> for all movies whose year is included in the range from 1980 to 1989 (the 80’s). The <code>..</code> operator is again an extension defined in <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java">IntegerExtensions</a> and returns an instance of <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerRange.java">IntegerRange</a>. Operator overloading is explained in <a href="203_xtend_expressions.html#operators">section</a>.</p>

<p>The resulting iterable is sorted (<a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java"><code>IterableExtensions.sortBy</code></a>) by the <code>rating</code> of the movies. Since it is sorted in ascending order, we take the last movie from the list and return its <code>year</code>.</p>
<p>The resulting iterable is sorted (<a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java"><code>IterableExtensions.sortBy</code></a>) by the <code>rating</code> of the movies. Since it is sorted in ascending order, we take the last movie from the list and return its <code>year</code>.</p>

<p>We could have sorted descending and take the head of the list as well:</p>

Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.xtend.doc/contents/201_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 id="conversion-rules">Conversion Rules</h2>

<p>The conversion works the other way round, too. In fact, all subtypes of <a href="https://docs.oracle.com/javase/11/docs/api/java/lang/Iterable.html">Iterable</a> are automatically converted to arrays on demand.</p>

<p>Another very useful conversion applies to lambda expressions. A lambda expression usually is of one of the types declared in <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Functions.java">Functions</a> or <a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Procedures.java">Procedures</a>. However, if the expected type is an interface or a class with a single abstract method declaration, a lambda expression is automatically converted to that type. This allows to use lambda expressions with many existing Java libraries. See <a href="203_xtend_expressions.html#closure-types">Lambda Expression Typing</a> for more details.</p>
<p>Another very useful conversion applies to lambda expressions. A lambda expression usually is of one of the types declared in <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Functions.java">Functions</a> or <a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Procedures.java">Procedures</a>. However, if the expected type is an interface or a class with a single abstract method declaration, a lambda expression is automatically converted to that type. This allows to use lambda expressions with many existing Java libraries. See <a href="203_xtend_expressions.html#closure-types">Lambda Expression Typing</a> for more details.</p>

<hr />

Expand Down
16 changes: 8 additions & 8 deletions org.eclipse.xtend.doc/contents/202_xtend_classes_members.html
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,14 @@ <h3 id="library-extensions">Extensions from the Library</h3>
<p>Have a look at the JavaDoc to learn about the available functionality:</p>

<ul>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java">ObjectExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java">IterableExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java">MapExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java">ListExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/CollectionExtensions.java">CollectionExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/BooleanExtensions.java">BooleanExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java">IntegerExtensions</a></li>
<li><a href="https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java">FunctionExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java">ObjectExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java">IterableExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java">MapExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java">ListExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/CollectionExtensions.java">CollectionExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/BooleanExtensions.java">BooleanExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java">IntegerExtensions</a></li>
<li><a href="https://github.com/eclipse-xtext/xtext/tree/main/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java">FunctionExtensions</a></li>
</ul>

<h3 id="local-extension-methods">Local Extension Methods</h3>
Expand Down
Loading

0 comments on commit 733043f

Please sign in to comment.