mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RunLineMarkerProvider reworked
This commit is contained in:
-7
@@ -34,9 +34,7 @@ import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -125,11 +123,6 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
return ProgramRunnerUtil.shortenName(JavaExecutionUtil.getShortClassName(MAIN_CLASS_NAME), 6) + ".main()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLineMarkerPlace(PsiElement place, PsiElement sourceElement) {
|
||||
return place instanceof PsiMethod && PsiTreeUtil.getParentOfType(place, PsiClass.class) == sourceElement && PsiMethodUtil.isMainMethod((PsiMethod)place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainClassName(final String qualifiedName) {
|
||||
MAIN_CLASS_NAME = qualifiedName;
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.application;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider;
|
||||
import com.intellij.execution.lineMarker.RunLineMarkerInfo;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class ApplicationRunLineMarkerProvider implements LineMarkerProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiClass && PsiMethodUtil.findMainInClass((PsiClass)element) != null)
|
||||
return new RunLineMarkerInfo(element, ApplicationConfigurationType.getInstance().getIcon(), null);
|
||||
if (element instanceof PsiMethod && PsiMethodUtil.isMainMethod((PsiMethod)element))
|
||||
return new RunLineMarkerInfo(element, ApplicationConfigurationType.getInstance().getIcon(), null);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user