Skip to content

Commit

Permalink
WIP #162 Add signature help for ENV
Browse files Browse the repository at this point in the history
Signed-off-by: Remy Suen <[email protected]>
  • Loading branch information
rcjsuen committed Aug 29, 2017
1 parent f4c186f commit e108eba
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 151 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
- HEALTHCHECK CMD flags
- instructions ([#162](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/162))
- ARG
- ENV
- EXPOSE
- FROM
- LABEL
Expand Down
14 changes: 14 additions & 0 deletions src/dockerPlainText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export class PlainTextDocumentation {
"signatureArg_Signature1_Param1": "The default value of the variable.",
"signatureCopyFlagFrom": "Set the build stage to use as the source location of this copy instruction instead of the build's context.",
"signatureCopyFlagFrom_Param": "The build stage or image name to use as the source. Also may be a numeric index.",
"signatureEnv_Signature0": "Set an environment variable to the specified value. The value will be in the environment of any descendent Dockerfiles",
"signatureEnv_Signature0_Param0": "The name of the environment variable.",
"signatureEnv_Signature0_Param1": "The value to set the environment variable to.",
"signatureExpose": "Define network ports for this container to listen on at runtime.",
"signatureExpose_Param0": "The port that this container should listen on.",
"signatureFrom_Signature0": "Set the base image to use for any subsequent instructions that follow.",
Expand Down Expand Up @@ -205,6 +208,17 @@ export class PlainTextDocumentation {
signatureArg_Signature1_Param1: this.dockerMessages["signatureArg_Signature1_Param1"],
signatureCopyFlagFrom: this.dockerMessages["signatureCopyFlagFrom"],
signatureCopyFlagFrom_Param: this.dockerMessages["signatureCopyFlagFrom_Param"],
signatureEnv_Signature0: this.dockerMessages["signatureEnv_Signature0"],
signatureEnv_Signature0_Param0: this.dockerMessages["signatureEnv_Signature0_Param0"],
signatureEnv_Signature0_Param1: this.dockerMessages["signatureEnv_Signature0_Param1"],
signatureEnv_Signature1: this.dockerMessages["signatureEnv_Signature0"],
signatureEnv_Signature1_Param0: this.dockerMessages["signatureEnv_Signature0_Param0"],
signatureEnv_Signature1_Param1: this.dockerMessages["signatureEnv_Signature0_Param1"],
signatureEnv_Signature2: this.dockerMessages["signatureEnv_Signature0"],
signatureEnv_Signature2_Param0: this.dockerMessages["signatureEnv_Signature0_Param0"],
signatureEnv_Signature2_Param1: this.dockerMessages["signatureEnv_Signature0_Param1"],
signatureEnv_Signature2_Param2: this.dockerMessages["signatureEnv_Signature0_Param0"],
signatureEnv_Signature2_Param3: this.dockerMessages["signatureEnv_Signature0_Param1"],
signatureExpose: this.dockerMessages["signatureExpose"],
signatureExpose_Param0: this.dockerMessages["signatureExpose_Param0"],
signatureExpose_Param1: this.dockerMessages["signatureExpose_Param0"],
Expand Down
89 changes: 72 additions & 17 deletions src/dockerSignatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Instruction } from './parser/instruction';
import { Property } from './parser/property';
import { Arg } from './parser/instructions/arg';
import { Copy } from './parser/instructions/copy';
import { Env } from './parser/instructions/env';
import { From } from './parser/instructions/from';
import { Healthcheck } from './parser/instructions/healthcheck';
import { Label } from './parser/instructions/label';
Expand Down Expand Up @@ -158,60 +159,60 @@ export class DockerSignatures {
}
}
break;
case "LABEL":
const labelSignatures = [
case "ENV":
const envSignatures = [
{
label: "LABEL key value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0"),
label: "ENV key value",
documentation: this.documentation.getDocumentation("signatureEnv_Signature0"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0_Param0")
documentation: this.documentation.getDocumentation("signatureEnv_Signature0_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0_Param1")
documentation: this.documentation.getDocumentation("signatureEnv_Signature0_Param1")
}
]
},
{
label: "LABEL key=value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1"),
label: "ENV key=value",
documentation: this.documentation.getDocumentation("signatureEnv_Signature1"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1_Param0")
documentation: this.documentation.getDocumentation("signatureEnv_Signature1_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1_Param1")
documentation: this.documentation.getDocumentation("signatureEnv_Signature1_Param1")
}
]
},
{
label: "LABEL key=value key2=value2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2"),
label: "ENV key=value key2=value2",
documentation: this.documentation.getDocumentation("signatureEnv_Signature2"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param0")
documentation: this.documentation.getDocumentation("signatureEnv_Signature2_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param1")
documentation: this.documentation.getDocumentation("signatureEnv_Signature2_Param1")
},
{
label: "key2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param2")
documentation: this.documentation.getDocumentation("signatureEnv_Signature2_Param2")
},
{
label: "value2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param3")
documentation: this.documentation.getDocumentation("signatureEnv_Signature2_Param3")
}
]
}
];
return this.getPropertySignatureHelp(document, position, labelSignatures, (instruction as Label).getProperties());
return this.getPropertySignatureHelp(document, position, envSignatures, (instruction as Env).getProperties());
case "EXPOSE":
let exposeSignatureHelp = {
signatures: [
Expand Down Expand Up @@ -318,6 +319,60 @@ export class DockerSignatures {
}
}
break;
case "LABEL":
const labelSignatures = [
{
label: "LABEL key value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature0_Param1")
}
]
},
{
label: "LABEL key=value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature1_Param1")
}
]
},
{
label: "LABEL key=value key2=value2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2"),
parameters: [
{
label: "key",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param0")
},
{
label: "value",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param1")
},
{
label: "key2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param2")
},
{
label: "value2",
documentation: this.documentation.getDocumentation("signatureLabel_Signature2_Param3")
}
]
}
];
return this.getPropertySignatureHelp(document, position, labelSignatures, (instruction as Label).getProperties());
case "ONBUILD":
const onbuildArgs = instruction.getArguments();
if (onbuildArgs.length > 0 && onbuildArgs[0].isBefore(position)) {
Expand Down
Loading

0 comments on commit e108eba

Please sign in to comment.