mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
Don't lose the order of named elements in the scope (PY-25906)
At least it's useful for PY-25906, methods will be shown in the order as they are declared.
This commit is contained in:
@@ -1,18 +1,6 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
package com.jetbrains.python.codeInsight.dataflow.scope.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -62,6 +50,7 @@ public class ScopeImpl implements Scope {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScopeVariable getDeclaredVariable(@NotNull final PsiElement anchorElement,
|
||||
@NotNull final String name) throws DFALimitExceededException {
|
||||
computeScopeVariables();
|
||||
@@ -85,6 +74,7 @@ public class ScopeImpl implements Scope {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal(final String name) {
|
||||
if (myGlobals == null || myNestedScopes == null) {
|
||||
collectDeclarations();
|
||||
@@ -100,6 +90,7 @@ public class ScopeImpl implements Scope {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNonlocal(final String name) {
|
||||
if (myNonlocals == null || myNestedScopes == null) {
|
||||
collectDeclarations();
|
||||
@@ -114,6 +105,7 @@ public class ScopeImpl implements Scope {
|
||||
return myAugAssignments.contains(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsDeclaration(final String name) {
|
||||
if (myNamedElements == null || myImportedNameDefiners == null) {
|
||||
collectDeclarations();
|
||||
@@ -190,7 +182,7 @@ public class ScopeImpl implements Scope {
|
||||
}
|
||||
|
||||
private void collectDeclarations() {
|
||||
final Map<String, Collection<PsiNamedElement>> namedElements = new HashMap<>();
|
||||
final Map<String, Collection<PsiNamedElement>> namedElements = new LinkedHashMap<>();
|
||||
final List<PyImportedNameDefiner> importedNameDefiners = new ArrayList<>();
|
||||
final List<Scope> nestedScopes = new ArrayList<>();
|
||||
final Set<String> globals = new HashSet<>();
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -115,7 +103,7 @@ public class PyOverrideTest extends PyTestCase {
|
||||
|
||||
public void testImplement() {
|
||||
myFixture.configureByFile("override/" + getTestName(true) + ".py");
|
||||
PyFunction toImplement = getTopLevelClass(0).getMethods()[0];
|
||||
PyFunction toImplement = getTopLevelClass(0).getMethods()[1];
|
||||
PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), getTopLevelClass(1),
|
||||
Collections.singletonList(new PyMethodMember(toImplement)), true);
|
||||
myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
|
||||
|
||||
Reference in New Issue
Block a user