-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmope_common.py
46 lines (38 loc) · 1.33 KB
/
mope_common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Commons for all Sublime commands
import sublime
import sublime_plugin
import os.path as path
import json
from .logger import *
def read_project_file(rootDir, projectFile):
if path.exists(projectFile):
#read file and convert into map/json object
log.debug("project file exists")
with open(projectFile, "r") as file:
return file.read()
else:
#create file with project informations
log.warn("project file doesn't exist")
with open(projectFile, "w") as file:
data = { "path": rootDir, "outputDirectory": "target" }
jsonStr = json.dumps(data, indent=2)
file.write(jsonStr)
return jsonStr
def isModelica():
openedFile = currentFile()
return openedFile.endswith(".mo")
def currentFile():
return sublime.active_window().active_view().file_name()
def fullWordBelowCursor(view, pos=None):
cursorPos = pos if pos is not None else view.sel()[0]
expandedRegion = view.expand_by_class(cursorPos, sublime.CLASS_WORD_START, " ")
return view.substr(expandedRegion).strip()
# currently not used because sublime text API doesn't provide a listener for "user selects a completion"
def queryPopupContent(description, link=None):
if description is not None:
return "".join(["<div>",
"<span style=\"margin-right: 5px;\">this is the awesome documentation string</span>",
"<a href=\"#\">more</a>",
"</div>"])
else:
return None