In order to help TexStudio with its intellisense, I wrapped a \lstnewenvironment inside a \newenvironment. This allowed TeXStudio to properly highlight the newly defined environment.
However, when I do that and procede to write a danish character (æøå) then it will fail, saying the inputenc package cannot handle the character.
\documentclass{article}
\usepackage{listings}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\lstnewenvironment{XJavaCode}[2]
{\lstset{language=Java, caption=#1, label=#2}}
{}
\newenvironment{JavaCode}[2]
{\begin{XJavaCode}{#1}{#2}}
{\end{XJavaCode}}
\begin{document}
\begin{JavaCode}{caption}{label}
ASD
\end{JavaCode}
æøå
\end{document}
lstlistingdoesn't work properly within an user-defined environment, that's why\lstnewenvironmentexists and why you should not wrap it inside another environment definition. – Tiuri Aug 28 '17 at 20:19\lstnewenvironmentas you can not use\newenvironment– David Carlisle Aug 28 '17 at 20:23\lstnewenvironmentvery well, but that's on them I guess. – LukasPJ Aug 28 '17 at 20:55