Skip to content

Commit

Permalink
Merge branch 'dev' into staticDiagram-hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Jul 26, 2017
2 parents 65f8869 + 0acf547 commit 3671ec0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ changelog.txt
CHANGELOG.md
xtend-gen
eclipse
.classpath
.project
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class WollokDslQuickfixProvider extends DefaultQuickfixProvider {
protected def quickFixForUnresolvedRefToVariable(IssueResolutionAcceptor issueResolutionAcceptor, Issue issue,
IXtextDocument xtextDocument, EObject target) {
// issue #452 - contextual menu based on different targets
val targetContext = target.getSelfContext
val targetContext = target.declaringContext // target.getSelfContext
val hasMethodContainer = targetContext !== null
val hasParameters = target.declaringMethod !== null && target.declaringMethod.parameters !== null
val canCreateLocalVariable = target.canCreateLocalVariable
Expand Down Expand Up @@ -410,9 +410,9 @@ class WollokDslQuickfixProvider extends DefaultQuickfixProvider {
issueResolutionAcceptor.accept(issue, Messages.WollokDslQuickFixProvider_create_new_class_name,
Messages.WollokDslQuickFixProvider_create_new_class_description, "class.png") [ e, context |
val newClassName = xtextDocument.get(issue.offset, issue.length)
val container = (e as WExpression).method.declaringContext
context.xtextDocument.replace(container.after, 0,
System.lineSeparator + CLASS + blankSpace + newClassName + " {" + System.lineSeparator + "}" + System.lineSeparator)
val container = e.container
context.xtextDocument.replace(container.before, 0,
CLASS + blankSpace + newClassName + " {" + System.lineSeparator + System.lineSeparator + "}" + System.lineSeparator + System.lineSeparator)
]

}
Expand Down Expand Up @@ -579,6 +579,8 @@ class WollokDslQuickfixProvider extends DefaultQuickfixProvider {
/** Extending to related files of project
* @See https://kthoms.wordpress.com/2011/07/12/xtend-generating-from-multiple-input-models/
*/
// TODO: import static extension WEclipseUtils
// eObject.getFile.refreshProject but also do a full refresh of this rename in whole project
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ import static extension org.uqbar.project.wollok.utils.WEclipseUtils.allWollokFi
*/
class WMethodContainerExtensions extends WollokModelExtensions {

def static EObject getContainer(EObject it) {
EcoreUtil2.getContainerOfType(it, WMethodContainer) ?: EcoreUtil2.getContainerOfType(it, WTest)
}

def static WMethodContainer declaringContext(EObject it) { EcoreUtil2.getContainerOfType(it, WMethodContainer) }

def static WMethodDeclaration declaringMethod(EObject it) { EcoreUtil2.getContainerOfType(it, WMethodDeclaration) }
Expand Down Expand Up @@ -405,13 +409,18 @@ class WMethodContainerExtensions extends WollokModelExtensions {
ele.getSelfContext !== null
}

/**
* We should use declaringContext instead
*/
@Deprecated
def static getSelfContext(EObject ele) {
for (var e = ele; e !== null; e = e.eContainer)
if (e.isSelfContext) return e
null
}

def dispatch static boolean canCreateLocalVariable(WFixture it) { false }
def dispatch static boolean canCreateLocalVariable(WTest it) { true }
def dispatch static boolean canCreateLocalVariable(WMethodContainer it) { true }
def dispatch static boolean canCreateLocalVariable(WProgram it) { true }
def dispatch static boolean canCreateLocalVariable(EObject ele) {
Expand Down

0 comments on commit 3671ec0

Please sign in to comment.