Skip to content

Commit

Permalink
Merge pull request #785 from aml-org/r/5.1.6
Browse files Browse the repository at this point in the history
Release 5.1.6
  • Loading branch information
llibarona authored Jul 5, 2022
2 parents 491d401 + 44f1867 commit 4ede687
Show file tree
Hide file tree
Showing 166 changed files with 10,381 additions and 1,412 deletions.
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pipeline {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
script {
try {
sh 'sbt -mem 6000 -Dsbt.global.base=.sbt -Dsbt.boot.directory=.sbt -Dsbt.ivy.home=.ivy2 clean coverage test coverageReport'
sh 'sbt -mem 6000 -Dsbt.global.base=.sbt -Dsbt.boot.directory=.sbt -Dsbt.ivy.home=.ivy2 clean coverage test coverageAggregate'
} catch (e) {
failedStage = failedStage + " TEST "
unstable "Failed tests"
Expand Down Expand Up @@ -251,10 +251,10 @@ pipeline {
slackSend color: '#00FF00', channel: "${slackChannel}", message: "${projectName} Published RC ${publish_version}"
} else if (env.BRANCH_NAME == 'master') {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: ${projectName} Master Publish ${publish_version} OK! :ok_hand:"
} else if (currentBuild.getPreviousBuild() != null && currentBuild.getPreviousBuild().result != null && currentBuild.getPreviousBuild().result.toString() != 'SUCCESS') {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: ${projectName} Back to Green!! :ok_hand:\n\tBranch: ${env.BRANCH_NAME}\n(See ${env.BUILD_URL})\n"
} else {
} else if (currentBuild.getPreviousBuild() == null || currentBuild.getPreviousBuild().result == null) {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: ${projectName} build ${currentBuild.currentResult} !!! :ok_hand:\n\tBranch: ${env.BRANCH_NAME}\n(See ${env.BUILD_URL})\n"
} else if (currentBuild.getPreviousBuild().result.toString() != 'SUCCESS') {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: ${projectName} Back to Green!! :ok_hand:\n\tBranch: ${env.BRANCH_NAME}\n(See ${env.BUILD_URL})\n"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.mulesoft.als.common.ObjectInTree
import org.mulesoft.als.common.YamlUtils.isJson
import org.mulesoft.als.common.dtoTypes.PositionRange
import org.mulesoft.als.convert.LspRangeConverter
import org.mulesoft.als.declarations.DeclarationCreator
import org.mulesoft.amfintegration.AmfImplicits.{AmfAnnotationsImp, AmfObjectImp, BaseUnitImp, DialectImplicits}
import org.mulesoft.lsp.edit.TextEdit
import org.mulesoft.lsp.feature.common.Range
Expand All @@ -19,7 +20,12 @@ import org.yaml.render.{JsonRender, JsonRenderOptions, YamlRender, YamlRenderOpt
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

trait BaseElementDeclarableExtractors extends TreeKnowledge {
trait BaseElementDeclarableExtractors extends TreeKnowledge with DeclarationCreator {

protected val afterInfoRange: PositionRange =
afterInfoNode(params.bu, yPartBranch.map(_.isJson).getOrElse(params.bu.location().exists(_.endsWith(".json"))))
.map(p => PositionRange(p, p))
.getOrElse(PositionRange.TopLine)

private lazy val baseName: String =
amfObject
Expand Down Expand Up @@ -64,7 +70,7 @@ trait BaseElementDeclarableExtractors extends TreeKnowledge {
* indentation
*/
protected lazy val entryIndentation: Int =
yPartBranch.flatMap(_.closestEntry).map(_.range.columnFrom).getOrElse(0)
yPartBranch.flatMap(_.parentEntry.map(_.key)).map(_.range.columnFrom).getOrElse(0)

protected def positionIsExtracted: Boolean =
entryRange
Expand Down Expand Up @@ -101,14 +107,14 @@ trait BaseElementDeclarableExtractors extends TreeKnowledge {
entryRange.map(
TextEdit(
_,
JsonRender.render(rl.getOrElse(jsonRefEntry), entryIndentation, jsonOptions)
JsonRender.render(rl.getOrElse(jsonRefEntry), entryIndentation + jsonOptions.indentationSize, jsonOptions)
)
)
else if (params.definedBy.isJsonStyle)
entryRange.map(
TextEdit(
_,
s"\n${YamlRender.render(rl.getOrElse(jsonRefEntry), entryIndentation, yamlOptions)}\n"
s"\n${YamlRender.render(rl.getOrElse(jsonRefEntry), entryIndentation + yamlOptions.indentationSize, yamlOptions)}\n"
)
)
else // default as raml style if none defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.mulesoft.als.actions.codeactions.plugins.base.{CodeActionRequestParam
import org.mulesoft.als.actions.codeactions.plugins.declarations.samefile.ExtractSameFileDeclaration
import org.mulesoft.als.common.edits.AbstractWorkspaceEdit
import org.mulesoft.als.common.edits.codeaction.AbstractCodeAction
import org.mulesoft.als.convert.LspRangeConverter
import org.mulesoft.lsp.edit.{TextDocumentEdit, TextEdit}
import org.mulesoft.lsp.feature.common.VersionedTextDocumentIdentifier
import org.yaml.model.{YMapEntry, YNode}
Expand Down Expand Up @@ -39,7 +40,9 @@ trait ConverterExtractor[Original <: AmfObject, Result <: AmfObject]
jsonOptions,
yamlOptions,
params.alsConfigurationState
).map(de => TextEdit(rangeFromEntryBottom(de._2), s"\n${de._1}\n"))
).map(de =>
TextEdit(rangeFromEntryBottom(de._2).getOrElse(LspRangeConverter.toLspRange(afterInfoRange)), s"\n${de._1}\n")
)

def modifyEntry(original: Original): String

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package org.mulesoft.als.actions.codeactions.plugins.declarations.common

import org.mulesoft.als.actions.codeactions.plugins.base.CodeActionRequestParams
import org.mulesoft.als.common.dtoTypes.PositionRange
import org.mulesoft.als.declarations.DeclarationCreator

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

trait CreatesFileCodeAction {
trait CreatesFileCodeAction extends DeclarationCreator {
protected val params: CodeActionRequestParams

protected val afterInfoRange: PositionRange =
afterInfoNode(params.bu, params.uri.endsWith(".json"))
.map(p => PositionRange(p, p))
.getOrElse(PositionRange.TopLine)

protected val extension: String
protected val relativeUri: String = params.uri.substring(0, params.uri.lastIndexOf('/') + 1)
protected def completeUri(name: String) = s"$relativeUri$name.$extension"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ trait ExtractDeclarationsToLibrary extends CodeActionResponsePlugin with Creates
finalName(plainName)
.map(name => YNode(s"$name.raml").asEntry(aliasName).inMap.withKey("uses"))
.map(n => YamlRender.render(n, 0, options))
.map(t => Some(TextEdit(Range(common.Position(1, 0), common.Position(1, 0)), s"$t\n")))
.map(t => Some(TextEdit(LspRangeConverter.toLspRange(afterInfoRange), s"$t\n")))
}

protected val selectedElements: Seq[DomainElement] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import scala.concurrent.Future
trait ExtractSameFileDeclaration extends CodeActionResponsePlugin with ShapeExtractor {
protected val kindTitle: CodeActionKindTitle

protected def rangeFromEntryBottom(maybeEntry: Option[YMapEntry]): Range =
maybeEntry.map(_.value.value).collect { case m: YMap => m }.flatMap(_.entries.lastOption) match {
case Some(e) =>
protected def rangeFromEntryBottom(maybeEntry: Option[YMapEntry]): Option[Range] =
maybeEntry
.map(_.value.value)
.collect { case m: YMap => m }
.flatMap(_.entries.lastOption)
.map { e =>
val pos = PositionRange(e.range).`end`
LspRangeConverter.toLspRange(PositionRange(pos, pos))
case None => Range(Position(1, 0), Position(1, 0))
}
}

protected def appliesToDocument(): Boolean =
!params.bu.isFragment || params.bu
Expand All @@ -42,7 +44,9 @@ trait ExtractSameFileDeclaration extends CodeActionResponsePlugin with ShapeExtr

protected lazy val declaredElementTextEdit: Option[TextEdit] =
renderDeclaredEntry(amfObject, newName)
.map(de => TextEdit(rangeFromEntryBottom(de._2), s"\n${de._1}\n"))
.map(de =>
TextEdit(rangeFromEntryBottom(de._2).getOrElse(LspRangeConverter.toLspRange(afterInfoRange)), s"\n${de._1}\n")
)

protected def renderDeclaredEntry(amfObject: Option[AmfObject], name: String): Option[(String, Option[YMapEntry])] =
ExtractorCommon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class ExtractTraitCodeAction(override protected val params: CodeActionRequestPar

override protected val findDialectForSemantic: String => Option[(SemanticExtension, Dialect)] =
params.findDialectForSemantic

}

object ExtractTraitCodeAction extends CodeActionFactory with ExtractTraitKind {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package org.mulesoft.als.actions.codeactions.plugins.vocabulary

import amf.aml.client.scala.model.document.{Dialect, Vocabulary, kind}
import amf.aml.client.scala.model.domain.{
ClassTerm,
DatatypePropertyTerm,
NodeMapping,
ObjectPropertyTerm,
PropertyMapping,
PropertyTerm
}
import amf.aml.client.scala.model.domain._
import amf.aml.internal.render.emitters.vocabularies.VocabularyEmitter
import amf.aml.internal.render.plugin.SyntaxDocument
import amf.core.client.scala.vocabulary.Namespace
import amf.core.internal.remote.Mimes
import org.mulesoft.als.actions.codeactions.plugins.declarations.common.CreatesFileCodeAction
import org.mulesoft.als.common.YamlWrapper.AlsInputRange
import org.mulesoft.als.common.dtoTypes.{PositionRange, Position => DtoPosition}
import org.mulesoft.als.convert.LspRangeConverter
import org.mulesoft.amfintegration.AmfImplicits.{AmfAnnotationsImp, BaseUnitImp}
import org.mulesoft.lsp.configuration.FormatOptions
Expand Down Expand Up @@ -111,7 +103,7 @@ trait DialectActionsHelper extends CreatesFileCodeAction {
}
TextEdit(
LspRangeConverter.toLspRange(
usesYMapEntry.map(_.range.toPositionRange).getOrElse(PositionRange(DtoPosition(1, 0), DtoPosition(1, 0)))
usesYMapEntry.map(_.range.toPositionRange).getOrElse(afterInfoRange)
),
rendered
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentChanges:
+
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ documentChanges:
type: resourceType
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ documentChanges:
type: resourceType
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ documentChanges:
type: resourceType
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ documentChanges:
type: resourceType
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ documentChanges:
type: resourceType
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ documentChanges:
content: |-
+
{
"$ref": "#/components/parameters/newparameter"
}
"$ref": "#/components/parameters/newparameter"
}
-
from:
line: 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ documentChanges:
content: |-
+
{
"$ref": "#/components/parameters/newparameter"
}
"$ref": "#/components/parameters/newparameter"
}
-
from:
line: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ documentChanges:
content: |-
+
{
"$ref": "#/components/parameters/newparameter"
}
"$ref": "#/components/parameters/newparameter"
}
-
from:
line: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ documentChanges:
- trait
-
from:
line: 1
line: 2
column: 0
to:
line: 1
line: 2
column: 0
content: |
+
Expand Down
Loading

0 comments on commit 4ede687

Please sign in to comment.