Skip to content

Commit

Permalink
Suplementary files: Do not indent too much
Browse files Browse the repository at this point in the history
  • Loading branch information
vesal committed Oct 1, 2024
1 parent 494a368 commit 508b4f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions timApp/idesupport/ide_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
from timApp.idesupport.files import SupplementaryFile, is_in_filename
from tim_common.cs_utils import populated

DOTNET_VERSION = "net8.0"
DOTNET_VERSION = "net$(NETCoreAppMaximumVersion)" # "net8.0"
# see: https://www.meziantou.net/how-to-use-the-latest-target-framework-available-for-a-dotnet-sdk.htm


class Language:
"""
A language type handler for the IDE support.
Classes derived from this base type can define custom behavior for TIM language types.
If any language-clas is written to separate file, it must be imported here so that populated-function

Check warning on line 21 in timApp/idesupport/ide_languages.py

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"clas" should be "class".

Check warning on line 21 in timApp/idesupport/ide_languages.py

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"clas" should be "class".
will work.
"""

ttype: str | list[str] = "_language"
Expand Down Expand Up @@ -138,7 +141,8 @@ def generate_supplementary_files(
proj_file = SupplementaryFile(
filename=f"{self.ide_task_id}.csproj",
content=textwrap.dedent(
f"""<Project Sdk="Microsoft.NET.Sdk">
f"""\
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>{DOTNET_VERSION}</TargetFramework>
Expand All @@ -164,7 +168,8 @@ def generate_supplementary_files(
proj_file = SupplementaryFile(
filename=f"{self.ide_task_id}.csproj",
content=textwrap.dedent(
f"""<Project Sdk="Microsoft.NET.Sdk">
f"""\
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>{DOTNET_VERSION}</TargetFramework>
Expand All @@ -191,7 +196,8 @@ def generate_supplementary_files(
main_file = SupplementaryFile(
filename="Ohjelma.cs",
content=textwrap.dedent(
f"""using System;
f"""\
using System;
namespace {self.classname};
public static class Program
{{
Expand Down
1 change: 1 addition & 0 deletions timApp/modules/cs/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
3. Mimic some existing language when creating the new class
- the simplest one is CC that works when just compiler name end extensions are enough to change
4. Add language to csPlugin.ts LanguageTypes.languages dictionary
5. If language is added to separate file, add import to manager.py file
"""

cmdline_whitelist = "A-Za-z\\-/\\.åöäÅÖÄ 0-9_"
Expand Down
13 changes: 13 additions & 0 deletions timApp/modules/cs/manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# TODO: Import and register all languages etc explicitly (= without using star imports).
from modifiers import *
from languages import *

# All languages must be imported for populated even not used in this file
# noinspection PyUnresolvedReferences
from geogebra import *

# noinspection PyUnresolvedReferences
from jsframe import *
from stack import *

# noinspection PyUnresolvedReferences
from extcheck import ExtCheck

# noinspection PyUnresolvedReferences
from gitlang import GitReg, GitCheck
from tim_common.cs_utils import populated

Expand All @@ -20,6 +29,8 @@ def all_js_files():

def add(dictionary):
for cls in dictionary.values(): # ask needed js and css files from language
# no time to find what files could throw
# noinspection PyBroadException
try:
files.update(cls.js_files())
except:
Expand All @@ -39,6 +50,8 @@ def all_css_files():

def add(dictionary):
for cls in dictionary.values(): # ask needed js and css files from language
# no time to find what files could throw
# noinspection PyBroadException
try:
files.update(cls.css_files())
except:
Expand Down

0 comments on commit 508b4f4

Please sign in to comment.